Issue
I want to have all modules imported from node_modules as external. What is the configuration for this?
I tried without success :
import path from "path";
import glob from "glob";
import multiEntry from "rollup-plugin-multi-entry";
export default {
entry: "src/**/*.js",
format: "cjs",
plugins: [
multiEntry()
],
external: glob.sync("node_modules/**/*.js").map(file => path.resolve(file)),
dest: "dist/bundle.js"
}];
or
import multiEntry from "rollup-plugin-multi-entry";
export default {
entry: "src/**/*.js",
format: "cjs",
plugins: [
multiEntry()
],
external: id => id.indexOf("node_modules") !== -1,
dest: "dist/bundle.js"
}];
Solution
You can accomplish that using package.json dependencies field:
const pkg = require('./package.json');
export default {
// ...
external : Object.keys(pkg.dependencies),
// ...
}
Answered By - Isidrok Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.