-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
🐛 bug report
🎛 Configuration
package.json
{
...
"source": "src/App/index.js",
"module": "dist/output.js",
"scripts": {
...
"start": "parcel src/index.html --dist-dir debug",
"build": "parcel build --no-content-hash --no-source-maps"
},
"targets": {
"module": {
"context": "browser",
"includeNodeModules": true,
"optimize": true
}
},
"alias": {
"process": {
"global": "{}"
}
},
"dependencies": {
"@popperjs/core": "^2.11.6",
"classnames": "^2.3.2",
"css-loader": "^6.8.1",
"cytoscape": "^3.25.0",
"cytoscape-fcose": "^2.2.0",
"cytoscape-node-html-label": "^1.2.2",
"cytoscape-popper": "^2.0.0",
"html2canvas": "^1.4.1",
"lodash.debounce": "^4.0.8",
"redux-batched-subscribe": "^0.1.6",
"redux-saga": "^1.2.3",
"tippy.js": "^2.6.0",
"vanjs-core": "^1.2.1"
},
"devDependencies": {
"@parcel/optimizer-data-url": "^2.11.0",
"@parcel/transformer-inline-string": "^2.11.0",
"@parcel/transformer-sass": "^2.11.0",
"@reduxjs/toolkit": "^1.9.5",
"@types/cytoscape": "^3.19.11",
"@types/cytoscape-fcose": "^2.2.4",
"@types/redux-batched-subscribe": "^0.1.4",
"parcel": "^2.11.0",
"process": "^0.11.10"
}
}tsconfig.json
{
"compilerOptions": {
"baseUrl": "./src",
"target": "ES2019",
"module": "ES2020",
"allowJs": true,
"checkJs": true,
"moduleResolution": "node",
"paths": {
"/*": [
"../*"
],
}
},
"exclude": [
"dist",
"debug",
"public/example",
"node_modules"
]
}🤔 Expected Behavior
css should not be imported into JS bundle
😯 Current Behavior
After build is done, i get following output in dist/output.js:
import"./pcr.css";function t(t,e,n,r){Object.defineProperty(t,e,{get:n,set:r...which obviously does not work in browser:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec. is given for the import of pcr.css
💁 Possible Solution
not sure if my configuration is correct (was not really straightforward and took my a while to find proper settings in both parcel docs, github issues and stackoverflow), but generally, there's no reason to include CSS in browser context
🔦 Context
export an app as a ES module that can be included in a webpage
💻 Code Sample
using (s)css modules in my JS, vanJS and redux, but not any opinionated framework such as React
...
import * as cssTab from './Components/ControlPanel/Tab/styles.module.scss';
import * as cssTabItem from './Components/ControlPanel/TabMenu/Item/styles.module.scss';
import * as style from 'bundle-text:scss/cytoscape.scss';
import 'scss/index.scss';
...🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 2.11 |
| Node | 18.17.0 |
| npm/Yarn | 9.6.7 |
| Operating System | Win11 x64 |