Improved file structure for Node.js
Notable changes
To support both different module systems in Node.js, there are 2 different types of modules are built:-
index.mjs
- ES Modules in Node.js favors.mjs
extension.index.js
- CommonJS in Node.js favors.js
extension.
In package.json
, by specifiying main: dist/index
. The correct file will be picked up by the module system used by the users.
This allows more straightforward and intuitive approach when using the module without the need to worry much about which file is used correctly:
ES Modules
import { html } from 'lit-ntml'; /** This reads content from `index.mjs` */
CommonJS
const { html } = require('lit-ntml'); /** This reads content from `index.js` */
🎉 Voila! Happy templating!