{
"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
}
}
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