@architect/plugin-bundles
Advanced tools
Comparing version 2.0.0 to 3.0.0
{ | ||
"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 } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15330
2
4
60
+ Added@architect/functions@^5.1.0
+ Added@architect/functions@5.4.1(transitive)
+ Addedcookie@0.5.0(transitive)
+ Addedcookie-signature@1.2.2(transitive)
+ Addedcsrf@3.1.0(transitive)
+ Addednode-webtokens@1.0.4(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedrandom-bytes@1.0.0(transitive)
+ Addedrndm@1.2.0(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedrun-waterfall@1.1.7(transitive)
+ Addedtsscmp@1.0.6(transitive)
+ Addeduid-safe@2.1.5(transitive)