You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a .cjs extension in the main field of package.json (e.g. "main": "./dist/foo.cjs") as per README causes microbundle to swallow any .css or .scss files imported
copy source/exports/main/module/unpkg fields into package.json as per README
{
"name": "foo", // your package name
"type": "module",
"source": "src/foo.js", // your source code
"exports": "./dist/foo.modern.js", // where to generate the modern bundle (see below)
"main": "./dist/foo.cjs", // where to generate the CommonJS bundle
"module": "./dist/foo.module.js", // where to generate the ESM bundle
"unpkg": "./dist/foo.umd.js", // where to generate the UMD bundle (also aliased as "umd:main")
"scripts": {
"build": "microbundle", // compiles "source" to "main"/"module"/"unpkg"
"dev": "microbundle watch" // re-build when source files change
}
}
update source field to point to index.js
npm run build
Actual output
All compiled formats of index.js
Below error message
The emitted file "foo.cjs" overwrites a previously emitted file of the same name.
Expected output
All compiled formats of index.js
styles.css
No error message
Workaround
Change the file extension of the main field from ./dist/foo.cjs -> ./dist/foo.js
= achieves expected output
Using a
.cjsextension in themainfield ofpackage.json(e.g."main": "./dist/foo.cjs") as per README causes microbundle to swallow any .css or .scss files importedReproduction steps
Repo: https://github.com/lokimckay-references/microbundle-883
npm init -ynpm install microbundle --save-devstyles.cssandindex.jsfilesimport "./styles.css"withinindex.jspackage.jsonas per READMEsourcefield to point toindex.jsnpm run buildActual output
Expected output
Workaround
Change the file extension of the
mainfield from./dist/foo.cjs->./dist/foo.js= achieves expected output