Comments (2)
Try to enable module
in SWC js minifier plugin.
from rspack.
I've simplified the reproduction.
This problem occurs when importing a "module"
package whose main file contains new URL("./", import.meta.url)
.
Both rspack and webpack will create an asset file xxx.js
for the main file itself because of the statement new URL("./", import.meta.url)
as documented: https://webpack.js.org/guides/asset-modules/#url-assets
Consider the foo
example, the package foo
has these two traits:
- there's
new URL("./", import.meta.url)
infoo/index.js
- is a
"module"
package
When importing foo
, both rspack and webpack will
- bundle content of
foo/index.js
into the main asset file - and also create an asset file
xxxx.js
whose content is same asfoo/index.js
When minimizing the xxxx.js
file, depending on the value of package "type"
package type of foo |
minimize | rspack | webpack |
---|---|---|---|
"module" |
ON | ❌[1] | ✅ |
"commonjs" |
ON | ❌[2] | ❌[2] |
"module" |
OFF | ✅ | ✅ |
"commonjs" |
OFF | ❌[2] | ❌[2] |
After dig into it, I just found
- failure [2] is dropped before minimizing which is as expected and has nothing to do with this issue.
- while [1] is dropped on minimizing which causes this issue.
- webpack minifies the file with
module: undefined
while rspack minifies it withmodule: false
from rspack.
Related Issues (20)
- [Bug]: Lazy compilation is not compatible with data URI entry points HOT 1
- [Bug]: Tree shaking not working HOT 6
- [Bug]: RSpack produces inflated bundle sizes as compared to other bundlers in a few cases
- [Bug]: ConcatenateModules optimization affect on sourcemaps HOT 3
- [Bug]: Rspack Dev Tools Slow when source-maps are generated using "eval" option
- [Bug]: Unable to load styled-components plugin HOT 7
- [Feature]: support ListenOptions in lazyCompilaton
- [Bug]: Using `concatenateModules` with `module` cause the entry module not inlined
- [Bug]: failed to receive tsfn value: RecvError HOT 3
- [Bug]: rspack compiling mdx files HOT 3
- [Bug]: Lazy compilation can not work with CssExtractRspackPlugin
- [Feature]: Provide detailed progress information HOT 2
- [Bug]: Panic occurred if require.context can not resolve the dir HOT 3
- [Bug]: Bundle Analyzer issue HOT 8
- [Bug]: `module.rules.descriptionData` won't apply conditions for custom resource description data
- [Bug]: HMR fails with RSPack v0.7.1 HOT 13
- [Bug]: Panic occurred at recompile in serve and watch mode with rspack 0.7.1 HOT 5
- [Bug]: Regression with rebuild/ recompile times with the latest rspack 0.7.1 HOT 14
- [Bug]: Rspack performing rebuild when started without watch HOT 2
- [Feature]: ModuleFederation: Unable to require trusted types via CSP HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspack.