-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Bug: JS v4.4.1 breaks with webpack, and changing resolve.conditionNames
configuration is not expected
#91
Comments
any solution @Martinocom-Switcho ? |
For now I downgraded to 4.1.1 and it works |
Can someone please post a sample app reproducing the issue? |
I can confirm the issue is that react-native seems to be taking the value for |
@tagliala @janroures @Martinocom-Switcho I just published v4.4.2-beta.0 with the fix (adding a specific import for react-native). Can you please give it a try? You can installed with |
|
@short-dsb thanks for reporting it back. I'm going to release 4.4.2 then. |
Same |
Thanks for the quick fix, @fnando. 🙂 |
Just released v4.4.2. |
@wooly let me try to quickly set up a small project using webpack. Could you please share your config (or the most relevant pieces of it) that I should use? |
Got it working. Looks like you need to add the /**
* @type {import('webpack').Configuration}
*/
module.exports = {
entry: "./index.js",
mode: "production",
target: "web",
resolve: {
conditionNames: ["import", "require", "module", "main"],
},
output: {
filename: "output.js",
path: __dirname,
},
}; I'm going to update the readme file with this info. |
I just wanted to mention that this is still an issue when using the latest version of Expo (v50) and bundling for web. I have tried customising the Metro config file as follows but then I got a different error:
|
@jbanulso did you try v4.4.2? It adds react-native as an export, so you don't need to tweak metro's config at all. I just started a brand new project with it and it worked out of box.
|
Hello, here it is a simple reproducible test case with webpack https://github.com/tagliala/i18n-js-issue-91 Didn't bisect (it is quite difficult for me as a non JavaScript developer. Also tried The support broke between 4.4.0 and 4.4.1 because of Line 33 in d32df06
Removing this line or moving it below "import" allows webpack to work It is this line: 4c4193a#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R33 |
@tagliala your sample works if you create a file /**
* @type {import('webpack').Configuration}
*/
module.exports = {
resolve: {
conditionNames: ["import", "require", "module", "main"],
},
}; Here's the whole thing in action: $ cat webpack.config.js && webpack && node dist/main.js
/**
* @type {import('webpack').Configuration}
*/
module.exports = {
resolve: {
conditionNames: ["import", "require", "module", "main"],
},
};
asset main.js 69.2 KiB [emitted] [minimized] (name: main)
orphan modules 64.5 KiB [orphan] 25 modules
runtime modules 1010 bytes 5 modules
modules by path ./node_modules/lodash/*.js 153 KiB
./node_modules/lodash/get.js 884 bytes [built] [code generated]
./node_modules/lodash/has.js 757 bytes [built] [code generated]
./node_modules/lodash/merge.js 1.19 KiB [built] [code generated]
./node_modules/lodash/uniq.js 688 bytes [built] [code generated]
./node_modules/lodash/_baseGet.js 616 bytes [built] [code generated]
./node_modules/lodash/_baseHas.js 559 bytes [built] [code generated]
./node_modules/lodash/_hasPath.js 1.06 KiB [built] [code generated]
./node_modules/lodash/_baseMerge.js 1.3 KiB [built] [code generated]
./node_modules/lodash/_createAssigner.js 1.02 KiB [built] [code generated]
+ 192 modules
./src/index.js + 24 modules 64.6 KiB [built] [code generated]
./node_modules/bignumber.js/bignumber.js 87.6 KiB [built] [code generated]
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
webpack 5.90.1 compiled with 1 warning in 758 ms
Hello World |
Thanks for your answer I can confirm that the change in configuration allows the reduced test case to pass. However, in a real application, there are several other packages, and when trying the change there the build breaks on other packages (an example is font awesome stylesheets) So I'm asking why this change is only needed by Even if we are trying to move out from webpacker, I can see that a similar issue also happens with esbuild, where a change to the main fields is required I've tried to understand https://webpack.js.org/guides/package-exports/ but it is unclear to me, so I have other questions:
|
I have a monorepo with With latest version 4.4.2, it works well on react-native but for my web app I still have the error I am not in the same context as the one of your example @fnando, I don't have webpack settings in my common package but only some webpacks params in my |
module.conditionNames
configuration is not expected
module.conditionNames
configuration is not expectedresolve.conditionNames
configuration is not expected
Is it possible to reopen this issue and implement a solution that does not require to change Since I cannot find a way to override "exports": {
".": {
+ "webpack": "./dist/import/index.js",
"browser": "./dist/browser/index.js",
"import": "./dist/import/index.js", or invert |
@tagliala I'm undoing this change. Can you please try v4.4.3-beta.0? |
@fnando I confirm that v4.4.3-beta.0 works again It is clear form the code because From the reproducible test case above:
|
On my side the latest v4.4.3-beta.0 works correctly in my monorepo for both react-native and react with webpack, thank you 👍 |
Thanks. Upgraded to 4.4.3, I can confirm the issue in the OP is fixed |
Incoming reproducible test case
https://github.com/diowa/icare/actions/runs/7872274448/job/21477141544?pr=1650#step:10:43
Relevant change: https://github.com/diowa/icare/pull/1650/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R32
Note
Sorry about the not-so-reduced test case. There are two JS errors, the second (google maps key) is unrelated. We are interested in the first one for this issue
Description
How to reproduce
What do you expect
Since this is a minor release, I was expected the same behaviour as before. Or at least an entry in the changelog and updated documentation
What happened instead
Breaks JavaScript functionality
Software:
Full backtrace
The text was updated successfully, but these errors were encountered: