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

@enhance/arc-plugin-rollup

Package Overview
Dependencies
Maintainers
7
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enhance/arc-plugin-rollup - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

16

package.json
{
"name": "@enhance/arc-plugin-rollup",
"version": "1.0.5",
"version": "1.1.0",
"description": "Use rollup.js to bundle pages for the browser in your Enhance project",

@@ -14,3 +14,3 @@ "main": "src/index.js",

"lint": "eslint src test --fix",
"test": "tape test/test.js | tap-arc"
"test": "tape test/**/*test.js | tap-arc"
},

@@ -34,6 +34,18 @@ "repository": {

"@architect/sandbox": "^5.4.1",
"eslint": "^8.32.0",
"tap-arc": "^0.3.5",
"tape": "^5.6.1",
"tiny-json-http": "^7.4.2"
},
"eslintConfig": {
"env": {
"node": true
},
"extends": "eslint:recommended",
"ignorePatterns": [],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2022
}
}
}

@@ -5,2 +5,3 @@ const { join } = require('path')

const { rollup } = require('rollup')
const { loadConfigFile } = require('rollup/loadConfigFile');
const resolve = require('@rollup/plugin-node-resolve')

@@ -33,11 +34,8 @@

const bundle = await rollup({
input: inFile,
plugins: [resolve()]
})
await bundle.write({
file: outFile,
format: 'es'
})
const rollupFile = join(cwd, 'rollup.config.js')
if(existsSync(rollupFile)) {
await externalRollup(rollupFile, inFile, outFile);
} else {
await internalRollup(inFile, outFile);
}
}

@@ -47,2 +45,49 @@ }

const internalRollup = async (inFile, outFile) => {
const bundle = await rollup({
input: inFile,
plugins: [resolve()]
})
await bundle.write({
file: outFile,
format: 'es'
})
}
const externalRollup = async (rollupFile, inFile, outFile) => {
let rollUpConfig = {}
let grab = memoize(loadConfigFile)
const { options, warnings } = await grab(rollupFile)
if(!warnings?.count) {
rollUpConfig = options
}
//eslint-disable-next-line no-undef
await Promise.all(rollUpConfig.map(async config => {
config.input = inFile
config.plugins = [resolve()]
const bundle = await rollup(config)
config.output.forEach(o => {
o.file = outFile
o.format = 'es'
})
//eslint-disable-next-line no-undef
await Promise.all(config.output.map(bundle.write))
}))
}
const memoize = (fn) => {
let cache = {};
return async (obj) => {
if(obj in cache) {
return cache[obj]
} else {
cache[obj] = await fn(obj)
return cache[obj]
}
}
}
module.exports = {

@@ -49,0 +94,0 @@ sandbox: {

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