CommonJS Require
arb opened this issue · 1 comments
I am trying to use the plugin to require
in package.json to include on the version information. When I look at the resultant bundling, the entire JSON object has been pulled in, recreated, and frozen with Object.freeze
. I've tried moving this plugin around to different spots in the plugins
array with no success.
My end goal is I just want the version
property.
My plugins stack looks like this
const plugins = [
resolve({
browser: true,
preferBuiltins: false,
}), json(), commonJs(), babel({
exclude: 'node_modules/**',
presets: ['es2015-rollup']
})];
This is an old issue and probably no longer relevant but just some feedback:
Tree-shaking in JSON files will only work if the file is imported using named ES modules imports. require
can only be translated into a default import which will always import the whole JSON file.
Feel free to reopen this if you need more clarification.