For questions please post on Stack Overflow and use the 'webpack' tag (http://stackoverflow.com/tags/webpack).
sokra on main
chore: add bugs field in packag… Merge pull request #15940 from … (compare)
sokra on main
ci: update github actions Merge pull request #15834 from … (compare)
sokra on main
fix: hmr build twice fix registry Merge pull request #15909 from … (compare)
sokra on main
enhanced-resolve@5.10.0 Merge pull request #16001 from … (compare)
sokra on up-enhanced-resolve
sokra on main
remove unnecessary moduleId pro… Merge pull request #16005 from … (compare)
sokra on moduleId-prop
pages/foo/bar.tsx
, I want to remove foo/
at compile time
Hi everyone!
I am an author of gradejs.com — a tool, that analyzes Webpack production bundles. It detects a list of bundled NPM libraries and works even for minified or tree-shaken bundles without access to the source code or Webpack stats files.
The project is free and open-sourced: https://github.com/gradejs/gradejs
We’ve just launched an open beta test and would like to get some feedback from the community.
webpackNode: "weak"
,yeah, I will open an issue, Thanks
@myNameIsDu the chat here is quite dead, you probably want to open an issue on the repo: https://github.com/webpack/webpack/issues/new/choose , failing that, I've gotten some help from the reactiflux discord: https://discord.com/invite/reactiflux
Hey, guys, I have a requirement to check whether the module exists at runtime and go back.Then i found magic comment Api
webpackNode: "weak"
,
But sometimes it doesn't work,Here's example
I am sorry, this is webpackMode: "weak"
yarn watch
, this is working properly.yarn upgrade @my/package --latest
, then webpack is compiling again, ok, good, but nothing has changed in reality.yarn watch
, run yarn upgrade then run yarn watch
, it's taking so much time ! (1minute ~)link:
but webpack is failing to compile.yarn watch
, this is working properly.yarn upgrade @my/package --latest
, then webpack is compiling again, ok, good, but nothing has changed in reality.yarn watch
, run yarn upgrade then run yarn watch
, it's taking so much time ! (1minute ~)link:
but webpack is failing to compile.hia, i have a node module that has .svg
files, i.e. @pkg/lib/svg/file.svg
and i'm trying to import these as just a string (like the asset/source
module rule does), however i can't seem to get anything to work for external/node modules - only relative ones.
how can i tell webpack to treat these as actual svg's, and not js/ts code?
this is the error i'm getting:
chunk (runtime: main) main.js (main) 4.44 KiB [entry] [rendered]
webpack compiled successfully (12dbe2b4c5152ac2)
Debugger listening on ws://localhost:9229/5929d9fa-ea2c-428e-9384-a6ed6ad34c76
Debugger listening on ws://localhost:9229/5929d9fa-ea2c-428e-9384-a6ed6ad34c76
For help, see: https://nodejs.org/en/docs/inspector
C:\Users\Ally\Documents\web\userscripts\node_modules\@material-design-icons\svg\sharp\forward_10.svg:1
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M18 13c0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6v4l5-5-5-5v4c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8h-2z"/><path d="M10.9 16v-4.27h-.09l-1.77.63v.69l1.01-.31V16zm3.42-4.22c-.18-.07-.37-.1-.59-.1s-.41.03-.59.1-.33.18-.45.33-.23.34-.29.57-.1.5-.1.82v.74c0 .32.04.6.11.82s.17.42.3.57.28.26.46.33.37.1.59.1.41-.03.59-.1.33-.18.45-.33.22-.34.29-.57.1-.5.1-.82v-.74c0-.32-.04-.6-.11-.82s-.17-.42-.3-.57-.29-.26-.46-.33zm.01 2.57c0 .19-.01.35-.04.48s-.06.24-.11.32-.11.14-.19.17-.16.05-.25.05-.18-.02-.25-.05-.14-.09-.19-.17-.09-.19-.12-.32-.04-.29-.04-.48v-.97c0-.19.01-.35.04-.48s.06-.23.12-.31.11-.14.19-.17.16-.05.25-.05.18.02.25.05.14.09.19.17.09.18.12.31.04.29.04.48v.97z"/></svg>
^
SyntaxError: Unexpected token '<'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.Module._load (C:\Users\Ally\Documents\web\userscripts\packages\node\src\executors\node\node-with-require-overrides.ts:16:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.@material-design-icons/svg/sharp/forward_10.svg (C:\Users\Ally\Documents\web\userscripts\dist\apps\youtube-extras\webpack:\userscripts\external commonjs "@material-design-icons\svg\sharp\forward_10.svg":1:1)
keeping in mind, it works perfectly fine if i import from e.g. ./file.svg
, but not a node module.
TypeError: leaflet__WEBPACK_IMPORTED_MODULE_0__.toLatLngBounds is not a function
but toLatLngBounds
is defined correctly in leafletjs. If anyone has any suggestions on where to look, I would appreciate it.
Hi everyone, I have a fairly complex webpack 5 script that works great on mac, and emits the files I expect (been lazy loading 5 years of code bloat now that I upgraded from react 15 to 16.14). Some of the dependencies of our react components were grouped into files automatically when I was lazy loading lots of pages in our app, so I setup various optimization->cacheGroups to accomodate the automatically grouped components that webpack was doing. Most of these worked and renamed to the file I wanted like for example:
"components-store-misc": {
chunks: 'all',
name: 'components-store-misc',
test(mod) {
if (!mod.context || !mod.userRequest) {
return false;
}
if (
mod.userRequest.includes('store/checkbox.js') ||
mod.userRequest.includes('store/velocityStoreLabel.js') ||
mod.userRequest.includes('components/infoPopup.js') ||
mod.userRequest.includes('components/search.js') ||
mod.userRequest.includes('components/store/label.js') ||
mod.userRequest.includes('components/components/infoPopup.js')
) {
return true;
} else {
return false;
}
},
}
Everything was working like a charm on mac osx (all groups that I specified were correct). But when compiling the same webpack on ubuntu 20.04 (our build server), it was not following the same configurations, so it output things like "430.js" on seemingly arbitrary dependencies (missed components that did not have dedicated lazy loaded files to go to).
My first question would be, why would webpack emit a numerical filename in ubuntu, vs a long name like javascript-components-componentName-ef54s.js. To resolve "javascript-components-componentName-ef54s.js" on the mac, I looked at what files it was wanting to group these dependencies in and created groups for them and things were happy. Several of these worked fine on the ubuntu side, but a few were problematic.
I have fixed my problem entirely and things are compiling properly on ubuntu now, but I wanted to understand more if someone knew about why webpack behaves different on different OSs. They are on the same webpack version too.
I added some email events when we compile our javascript to look for suspicious files because if webpack decides to compile 430.js or any numeric number, then when it hotloads the lazy component via a promise, it wont be there because we have to setup golang controllers to read these dist/ files for each emitted lazy loaded library/cacheGroup we have setup.
Thanks for listening to my long winded rant!
More "not my code, code of a sub-dependency...":
The package cypress-react-selector
tweaks the require function is used in a way in which dependencies cannot be statically extracted
warning. It's not a fatal error, just annoying enough that I'm looking into it. I believe the specific call that's getting in the way is require.hasOwnProperty('resolve')
in this
const file = require.hasOwnProperty('resolve')
? require.resolve('resq')
: 'node_modules/resq/dist/index.js';
Thoughts on a better way to do this, to be able to submit a PR for the maintainer to "fix" this?
Thx
Hello. I'm on lastest webpack 5. I'm currently moving from old gulp config to new webpack config but have troubles with dependOn functionality.
I'm using multiple entry points, some of which are used by other entries in dependOn lists.
all the bundles are generated, however I don't know how to generate bundle so that the top level entry is glued together with all dependencies pointed out in "dependOn" entries.
The top level entry does not have any exports, it just has dependOn with references to other entries and an empty "import" file - it exists but is entry
I target "web" - I tried the following libraryTargets, and added <script> tag to load the top level bundle (the one that pulls dependencies via dependOn). I also added html export plugin to see what is suggested.