Apk bundling error
The server starts on port 8081 and builds successfully but it stops bundling at some point and it throws this error Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({}) at Compiler.emit (node:events:508:17) at Worker. (C:\Users\directory\Documents\anotherHastro\node_modules@callstack\repack\dist\webpack\Compiler.js:97:14) at Worker.emit (node:events:519:28) at MessagePort. (node:internal/worker:263:53) at [nodejs.internal.kHybridDispatch] (node:internal/event_target:822:20) at exports.emitMessage (node:internal/per_context/messageport:23:28) { code: 'ERR_UNHANDLED_ERROR', context: {} }
Node.js v21.4.0
can you please help me look into it
Thanks
@omotayoR1 the error is very cryptic and doesn't provide anything meaningful, could you please share a reproduction repository so I can help you resolve this issue? Thanks!
@omotayoR1 the error is very cryptic and doesn't provide anything meaningful, could you please share a reproduction repository so I can help you resolve this issue? Thanks!
okay thank you
https://github.com/omotayoR1/quick-fix - repo url
@omotayoR1 the error is very cryptic and doesn't provide anything meaningful, could you please share a reproduction repository so I can help you resolve this issue? Thanks!
okay thank you
https://github.com/omotayoR1/quick-fix - repo url
Hello.. Please is there any update on this, Thanks
Hi @omotayoR1,
Thank you for providing the repro, I had some time and managed to find the root cause.
Fix
To fix it for now, you can add this to your webpack.config:
...
resolve: {
...Repack.getResolveOptions(platform),
extensions: [
`.${platform}.js`,
".native.js",
".js",
`.${platform}.jsx`,
".native.jsx",
".jsx",
`.${platform}.ts`,
".native.ts",
".ts",
`.${platform}.tsx`,
".native.tsx",
".tsx",
`.${platform}.json`,
".native.json",
".json",
]
},
Why this happened
On Windows, the paths are resolved without considering their case sensitivity. In index.js we have the following:
// index.js
import App from './App';
import {name as appName} from './app.json';
...
On Mac/Linux, import App from './App'; will resolve to ./App.tsx.
On Windows, it will resolve to ./app.json because the .json extension is listed before the .tsx in our defaults.
Our defaults now match closely what Metro has, but Metro seems to use case sensitivity paths on platforms.
Long term solution
This can be resolved following one of the paths:
The useful solution path
For Windows, we should change the order of extensions matched to match .json-like extensions last. This should provide most compatibility while only deviating slightly from the spec. In RN world, it is also common to include .json extension explicitly when importing such modules so the impact will be even smaller.
The right solution path
We should drop .json extension altogether and rely on user specifying the whole path. This will avoid conflicts like the one in question. Specifying extension explicitly will still work, we just won't try to match when importing from an extension-less path. This solution should prevent hard to debug situations on Windows platform but is less compatible because affects both platforms.
EDIT:
Some libraries might also rely on resolving .json extension without specyfing it explicitly and it might break them
Hi @omotayoR1,
Thank you for providing the repro, I had some time and managed to find the root cause.
Fix
To fix it for now, you can add this to your
webpack.config:... resolve: { ...Repack.getResolveOptions(platform), extensions: [ `.${platform}.js`, ".native.js", ".js", `.${platform}.jsx`, ".native.jsx", ".jsx", `.${platform}.ts`, ".native.ts", ".ts", `.${platform}.tsx`, ".native.tsx", ".tsx", `.${platform}.json`, ".native.json", ".json", ] },Why this happened
On Windows, the paths are resolved without considering their case sensitivity. In
index.jswe have the following:// index.js import App from './App'; import {name as appName} from './app.json'; ...On Mac/Linux,
import App from './App';will resolve to./App.tsx. On Windows, it will resolve to./app.jsonbecause the.jsonextension is listed before the.tsxin our defaults. Our defaults now match closely what Metro has, but Metro seems to use case sensitivity paths on platforms.Long term solution
This can be resolved following one of the paths:
The useful solution path
For Windows, we should change the order of extensions matched to match
.json-like extensions last. This should provide most compatibility while only deviating slightly from the spec. In RN world, it is also common to include.jsonextension explicitly when importing such modules so the impact will be even smaller.The right solution path
We should drop
.jsonextension altogether and rely on user specifying the whole path. This will avoid conflicts like the one in question. Specifying extension explicitly will still work, we just won't try to match when importing from an extension-less path. This solution should prevent hard to debug situations on Windows platform but is less compatible because affects both platforms.EDIT: Some libraries might also rely on resolving
.jsonextension without specyfing it explicitly and it might break them
Hello Thanks for helping. The issue persists with the same error message
@omotayoR1 did you apply the changes mentioned above? The fix will be released later this week. In the meantime please apply the changes to the reproduction so I can verify that the issue still persists and is not an environment issue.
Hi @omotayoR1,
Thank you for providing the repro, I had some time and managed to find the root cause.
Fix
To fix it for now, you can add this to your
webpack.config:... resolve: { ...Repack.getResolveOptions(platform), extensions: [ `.${platform}.js`, ".native.js", ".js", `.${platform}.jsx`, ".native.jsx", ".jsx", `.${platform}.ts`, ".native.ts", ".ts", `.${platform}.tsx`, ".native.tsx", ".tsx", `.${platform}.json`, ".native.json", ".json", ] },Why this happened
On Windows, the paths are resolved without considering their case sensitivity. In
index.jswe have the following:// index.js import App from './App'; import {name as appName} from './app.json'; ...On Mac/Linux,
import App from './App';will resolve to./App.tsx. On Windows, it will resolve to./app.jsonbecause the.jsonextension is listed before the.tsxin our defaults. Our defaults now match closely what Metro has, but Metro seems to use case sensitivity paths on platforms.Long term solution
This can be resolved following one of the paths:
The useful solution path
For Windows, we should change the order of extensions matched to match
.json-like extensions last. This should provide most compatibility while only deviating slightly from the spec. In RN world, it is also common to include.jsonextension explicitly when importing such modules so the impact will be even smaller.The right solution path
We should drop
.jsonextension altogether and rely on user specifying the whole path. This will avoid conflicts like the one in question. Specifying extension explicitly will still work, we just won't try to match when importing from an extension-less path. This solution should prevent hard to debug situations on Windows platform but is less compatible because affects both platforms.EDIT: Some libraries might also rely on resolving
.jsonextension without specyfing it explicitly and it might break them
Hello Thanks for helping. The issue persists with the same error message
@omotayoR1 did you apply the changes mentioned above? The fix will be released later this week. In the meantime please apply the changes to the reproduction so I can verify that the issue still persists and is not an environment issue.
Hello I applied the changes to the repro, please check thank you for helping
@omotayoR1 I've checked your repro but couldn't reproduce the problem, the app bundles normally on Windows now
@omotayoR1 I've checked your repro but couldn't reproduce the problem, the app bundles normally on Windows now
The app doesnt bundle completely on windows.
@omotayoR1 I've checked your repro but couldn't reproduce the problem, the app bundles normally on Windows now
Hello Thanks for helping... is there any update on this please
@omotayoR1 as I mentioned above, I can't reproduce this issue on the Windows machine, can you create a new issue with more details of the problems you are facing? Since you are saying that the problem is happening in the updated repro, can you add some screenshots or logs that showcase the problem? Perhaps I'm missing something something that's needed to reproduce this
@omotayoR1 as I mentioned above, I can't reproduce this issue on the Windows machine, can you create a new issue with more details of the problems you are facing? Since you are saying that the problem is happening in the updated repro, can you add some screenshots or logs that showcase the problem? Perhaps I'm missing something something that's needed to reproduce this
I will do that soon thanks