ProjectMirador / research-and-demos

Proofs of concept for Mirador 3
10 stars 8 forks source link

add build script for main npm package with named module export #78

Open christopher-johnson opened 5 years ago

christopher-johnson commented 5 years ago

an importable npm package is typically referenced with package.json that contains a main property. e.g. "main": "lib/index.js". To build this index.js file requires a distinct build script than the current distribution build. The entry point index only exports the App module and not the DOM element binding or the redux Provider or store, as these would be implemented by the downstream consumer.

For example, the entry point index-lib.js only contains.

export { App } from './components/App';
mejackreed commented 5 years ago

Is it possible here to handle both scenarios? I think we need to support:

christopher-johnson commented 5 years ago

sure you can do both, but not in the same package. I would prioritize ES6 above CJS require package support, since this is how want to use it. But there may those who prefer CJS. The way that I see it, ES6 is the future, so for a new app, I think it should be the target idiom. Anyway, if someone wants to use CJS, they can use the distribution, so npm is actually not required for them. npm is however required for those who want to import an ES6 module.