Comments (7)
This looks like an issue with "MetroJS bundler" not supporting .cjs
extensions natively.
Looks like you need to edit your existing metro.config.js
file (or make one if it does not already exist), then add cjs
to the resolver.sourceExts
array.
Let me know if the above StackOverflow solutions don't unblock you. I can see what else I can do, but I am ultimately relunctant to change the file extension of the bundled CommonJS file, because the different file extension is a requirement for newer versions of Node to distinguish CommonJS from ESM files in the same package.
from reactn.
Hi Charles,
Thanks for the library, could you release an update to reactn that has the fixed use-force-update dependency ? We use reactn in a LOT of projects...
Thanks,
Théo
from reactn.
I'm not positive why this is occurring, but thank you for bringing it to my attention. The file definitely exists.
I have historically been able to successfully assign main
as the CommonJS export and module
as the ESM export. For some reason, your build is expecting an ESM export (probably because your application is ESM and/or because use-force-update
uses the "type": "module"
property).
I believe a build tool that is looking for an ESM bundle should be using the module
property instead of the main
property. Nonetheless, I will attempt to resolve this by using exports
instead.
I'm pushing 1.0.10
right now. Give it a few hours to flow through CI/CD and for NPM caches to clear. Then update the nested dependency. I don't know the NPM command offhand, but the yarn command would be yarn up -R use-force-update
. You should also be able to do npm uninstall reactn && npm install reactn --save
to get a similar effect, as I assume use-force-update
is not being locked by any other dependency.
Let me know if 1.0.10 does not resolve this issue for you, and I'll continue the investigation. :)
EDIT: Here is the link to the CI/CD for [email protected]
from reactn.
Thanks for the quick response.
I’ve been testing the same project this was reported on, but on Android. The workaround of updating the package.json fixes the problem when doing a development build, but doesn’t seem to help on a production build.
This afternoon I updated our problem project with your new version 1.0.10 of use-force-update and tried again. The build is still failing.
Here’s the relevant section of the build log:
[stderr]
error While trying to resolve module use-force-update
from file /home/expo/workingdir/build/node_modules/reactn/build/use-dispatch.js
, the package /home/expo/workingdir/build/node_modules/use-force-update/package.json
was successfully found. However, this package itself specifies a main
module field that could not be resolved (/home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs
. Indeed, none of these files exist:
[stderr]
- /home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
[stderr] - /home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json).
Error: While trying to resolve moduleuse-force-update
from file/home/expo/workingdir/build/node_modules/reactn/build/use-dispatch.js
, the package/home/expo/workingdir/build/node_modules/use-force-update/package.json
was successfully found. However, this package itself specifies amain
module field that could not be resolved (/home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs
. Indeed, none of these files exist: - /home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
- /home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
at DependencyGraph.resolveDependency (/home/expo/workingdir/build/node_modules/metro/src/node-haste/DependencyGraph.js:436:17)
at Object.resolve (/home/expo/workingdir/build/node_modules/metro/src/lib/transformHelpers.js:317:42)
at resolve (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:629:33)
at /home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:645:26
at Array.reduce ()
at resolveDependencies (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:644:33)
at /home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:329:33
at Generator.next ()
at asyncGeneratorStep (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:24)
at _next (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:159:9)
info Run CLI with --verbose flag for more details.
Task :app:bundleReleaseJsAndAssets FAILED
[stderr]
FAILURE: Build failed with an exception.
Thanks for taking a look at this.
from reactn.
I edited metro.config.js using info from the Stack Overflow link you supplied and from https://docs.expo.dev/guides/customizing-metro/. The build is working well now, without me needing to futz with the use-force-update package.
Really appreciate your quick help in figuring this out.
from reactn.
Hi Charles,
Thanks for the library, could you release an update to reactn that has the fixed use-force-update dependency ? We use reactn in a LOT of projects...
Thanks,
Théo
This is blocking us as well. Is there anything we can do on our side to address this until it is resolved in the library?
from reactn.
@minuitagency @purplecones Have you tried the configuration change for Metro bundler? As it was initially reported, this is a problem with the Metro bundler, not the dependency, and the fix has already been included in this thread chain.
from reactn.
Related Issues (20)
- Can we drop in preact in place of React while using Reactn? HOT 1
- Global state resets after Route change HOT 5
- Don't export functions with the same name as common React hooks HOT 1
- [Query] Does updating a global nested state, require deep copy ? HOT 2
- why is useEffect exported from the package? HOT 2
- Dependabot can't resolve your JavaScript dependency files
- Provider.useDispatch Errors with TypeScript HOT 1
- Global reducers do not work in TypeScript 4. HOT 4
- Ability to update state with a function with globalPropertySetter HOT 1
- React Native expo HOT 2
- react native compatible? HOT 5
- Feature request: add previous global state to addCallback parameters HOT 10
- useEffect in useGlobal has no dependencies and will run every render HOT 1
- Document how to put arrays and etc. in global state HOT 6
- Unwanted batch rendering
- Argument of type 'string' is not assignable to parameter of type 'never' HOT 3
- Dispatch re-renders components even when state is unchanged. HOT 2
- Set `peerDependencies` to `"@types/react": "^16.8.0 | ^17.0.2"` HOT 2
- Dependency Use force update 1.0.10 causes a Type Error HOT 7
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 reactn.