Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@architect/plugin-bundles

Package Overview
Dependencies
Maintainers
6
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@architect/plugin-bundles - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

3

package.json
{
"name": "@architect/plugin-bundles",
"version": "2.0.0",
"version": "3.0.0",
"description": "plugin-bundles Plugin for exposing bundled modules to the browser from your Architect project.",

@@ -28,2 +28,3 @@ "main": "src/plugins/bundles/index.js",

"dependencies": {
"@architect/functions": "^5.1.0",
"esbuild": "^0.14.38"

@@ -30,0 +31,0 @@ },

@@ -1,17 +0,5 @@

const fs = require('fs')
const path = require('path')
const crypto = require('crypto')
const { build } = require('esbuild')
const GET_BUNDLES = 'get-_bundles'
const fs = require('fs')
const set = {
http() {
return {
method: 'get',
path: '/_bundles/*',
src: path.join(__dirname, '..', 'http', GET_BUNDLES)
}
}
}
const sandbox = {

@@ -58,11 +46,4 @@ async start ({ arc, inventory }) {

async function bundle (arc, inventory) {
const bundlesSrc = inventory.http.find(i => i.name === 'get /_bundles/*').src
const pathToBundles = path.join(
bundlesSrc,
'node_modules',
'@architect',
'bundles'
)
fs.mkdirSync(pathToBundles, { recursive: true })
const pathToStatic = process.env.ARC_STATIC_BUCKET
const pathToStaticBundles = path.join(pathToStatic, 'bundles')
for (let [ name, pathToFile ] of arc.bundles) {

@@ -74,32 +55,13 @@ let entry = path.join(inventory._project.cwd, pathToFile)

format: 'esm',
outfile: path.join(pathToBundles, `${name}.mjs`),
target: [ 'esnext' ],
platform: 'browser',
outfile: path.join(pathToStaticBundles, `${name}.mjs`),
})
}
// generate map
let map = 'export default {\n'
for (let [ name ] of arc.bundles) {
let pathToBrowserFile = path.join(pathToBundles, `${name}.mjs`)
let raw = fs.readFileSync(pathToBrowserFile).toString()
let hash = crypto.createHash('md5').update(raw).digest('hex').substring(0, 7)
map += ` "/_bundles/${name}.mjs": "/_bundles/${name}-${hash}.mjs",\n`
}
map += '}'
for (let name of inventory.lambdaSrcDirs) {
const lambda = inventory.lambdasBySrcDir[name]
if (lambda.method && lambda.method.toLowerCase() === 'get') {
const pathToLambdaBundles = path.join(
lambda.src,
'node_modules',
'@architect',
'bundles'
)
fs.mkdirSync(pathToLambdaBundles, { recursive: true })
const pathToBrowserIndex = path.join(pathToLambdaBundles, `map.mjs`)
fs.writeFileSync(pathToBrowserIndex, map)
}
}
fs.writeFileSync(
path.join(pathToStatic, '.gitignore'),
'bundles'
)
}
module.exports = { set, sandbox, deploy }
module.exports = { sandbox, deploy }
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc