-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module exports are not preserved when using dev-server with Webpack 5 beta #2484
Comments
Pr welcome |
A workaround for now at least is to set |
/cc @Loonride Can you look at this? |
I will take a look |
this problem still existed on webpack@5.1.0. |
this problem is still present in webpack@5.3.2 |
I still want liveReloading capability during developing of my library so i found a workaround.
modified webpack config:
and run dev server as works fine despite the fact that correct injection of the dev server client should be the following: But i'm looking forward to see this issue fixed. |
This is still an issue for me. "devDependencies": {
"webpack": "^5.4.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0",
} |
Duplicate of #2692 (it's a newer issue, but has more details). |
@ylemkimon yep, but it is different issues, but have the same origin |
@ylemkimon just check, do we have test for: |
webpack-dev-server/test/integration/ModuleFederation.test.js Lines 27 to 53 in e647af4
|
@ylemkimon good, for library? |
@evilebottnawi It tests for
|
@ylemkimon I mean testing |
Integrated functionality with Geonames, Weatherbit, and Pixabay APIs. -Geonames takes in the city name and responds with a list of places. The App will chose the first option. -Weatherbit will get historical weather data for the longitude and latitude provided from Geonames because it doesn't serve predictions too far out. Since the Weatherbit account is on the free version, it needs to call the API 7 times for a weeks worth of historical data. -Pixabay takes in the city and responds with an image for that location. As for the WebPack bug, there is an issue with wp5, webpack-dev-server and hot module replacement. Essentially it causes the library to empty, not allowing access to imported functions. The issue is found here: webpack/webpack-dev-server#2484 and offers a fix setting config.devServer.injectClient: false. This ends up disabling hot reload it seems but I can access the library and reload the page manually to see changes. I also added miscellaneous style changes as well as a countdown in days for the trips.
this problem is still present in webpack@5.10.3 |
Compatability issues with Webpack 5 were giving us an empty object for traceSearch when the test page was served via the dev server. See webpack/webpack-dev-server#2484
webpack-dev-server@4.0.0-beta.0 is work |
This doesn't seem to be fully fixed. While upgrading to For reference, here's the config i have for version 4 which still doesn't provide hot reload (i.e. the whole page refreshes every time a change occurs) config.devServer = {
historyApiFallback: true,
host: '0.0.0.0',
port: WEBPACK_PORT,
liveReload: true,
injectClient: true,
client: {
logging: 'none',
progress: false,
overlay: false,
host: '0.0.0.0',
port: WEBPACK_PORT,
},
static: [path.join(__dirname, '/'), path.join(__dirname, 'node_modules')],
};
config.infrastructureLogging = {
level: 'none',
};
config.stats = 'errors-only'; Using @ncastaldo 's fix the library object is correctly exposed, however only if i disable the So essentially right now it's impossible to have a correctly exposed library with hot reload, since in version 3 hot reload works, but the library cannot be exposed properly, and in version 4, it's exposed properly but hot reload is broken... Anyone else still encountering this? |
remove |
still an issue for me as well in webpack 5.28.0 with dev-server 4.0.0-beta.1 and cli 4.6.0. Solved this by just setting the window library explicitly in my index.js i.e.
then any js script can now access window.export_name.function_to_export edit: this seems to be an issue when running hot updates on the bundle after the initial build. It seems like webpack-dev-server just stops taking into account your output configuration |
We have tests on it, double check your version or provide example of the problem |
Works for me with |
**Why?** Webpack 5 has some important features for controlling how library code gets exposed in different environments. In our case, we will want to control how the behaviors are made available for use when each behavior bundle gets loaded. More on that later. This change is just updating the dependencies to make that possible. **What?** Update; * `webpack@5.36.0` to enable better output library features * `webpack-dev-server@4.0.0-beta.2` to get a version which is compatible with Webpack 5 and includes a fix for webpack/webpack-dev-server#2484 * `webpack-cli@4.6.0` to get a version of the CLI which works with the latest dev server * `copy-webpack-plugin@8.1.1` to fix a warning when building with Webpack 5
**Why?** Webpack 5 has some important features for controlling how library code gets exposed in different environments. In our case, we will want to control how the behaviors are made available for use when each behavior bundle gets loaded. More on that later. This change is just updating the dependencies to make that possible. **What?** Update; * `webpack@5.36.0` to enable better output library features * `webpack-dev-server@4.0.0-beta.2` to get a version which is compatible with Webpack 5 and includes a fix for webpack/webpack-dev-server#2484 * `webpack-cli@4.6.0` to get a version of the CLI which works with the latest dev server * `copy-webpack-plugin@8.1.1` to fix a warning when building with Webpack 5
This was much trickier than anticipated due to webpack/webpack-dev-server#2484 which necessitated upgrading to webpack-dev-server 4.0.0-rc.0
This was much trickier than anticipated due to webpack/webpack-dev-server#2484 which necessitated upgrading to webpack-dev-server 4.0.0-rc.0
Had to switch to the latest beta version due to a bug in the dev server: webpack/webpack-dev-server#2484
Works for me with {
"@pmmmwh/react-refresh-webpack-plugin": "0.5.0-rc.3",
"react-refresh": "0.10.0",
"webpack-cli": "4.8.0",
"webpack-dev-server": "4.0.0-rc.1"
} |
This was much trickier than anticipated due to webpack/webpack-dev-server#2484 which necessitated upgrading to webpack-dev-server 4.0.0-rc.0
Having the same problem with the latest possible setup + Module Federation Plugin:
This is in remoteEntry.js and I can't disable it because
|
If anyone is interested, the extra entry points disappeared after I set |
...
output: {
library: "GlobalName",
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
libraryTarget: 'umd',
libraryExport: 'default'
},
... This is accessed via GlobalName, work's ok in webpack5.x |
Code
Reproduction link: https://github.com/csvn/webpack-dev-server-export-issue-reproduction
Additional details
The entry point is messed up when when running
webpack-dev-server
. The exports will always be empty ({}
) due towebpack-dev-server
prepending it's entry points, which does not seem to yield the correct results with Webpack 5 beta.When using
webpack-dev-server
When using
webpack
buildExpected Behavior
Values exported from
main.js
should be available onwindow.main
.Actual Behavior
The exported object on
window.main
is{}
How can we reproduce the behavior?
npm start
(ornpx webpack-dev-server
main.js
missingThe text was updated successfully, but these errors were encountered: