Named exports
Rich-Harris opened this issue · 1 comments
Rich-Harris commented
Re @Victorystick's suggestion on rollup/rollup#269 (comment) – it'd be nice to import a single field from e.g. package.json. Right now, this plugin only generates a default export:
export default {
"name": "my-neato-package",
"version": "1.33.7",
"main": "dist/my-neato-package.umd.js",
...
};
We could easily generate named exports too:
export var name = "my-neato-package";
export var version = "1.33.7";
export var main = "dist/my-neato-package.umd.js";
export default {
name: name,
version: version,
main: main,
...
};
That way, import { version } from './package.json'
wouldn't include unnecessary gubbins.
It gets slightly tricky with key names that aren't valid identifiers, like jsnext:main
. Do we ignore them, or turn them into valid identifiers?
export var jsnext_main = 'dist/my-neato-package.es6.js';
export default {
'jsnext:main': jsnext_main,
...
};
Could also supply a function as an option that replaces keys for a given file.
Rich-Harris commented
Also, the above should only apply if the file describes an object, and not an array, because that would be weird