Closed jeeeckson closed 5 years ago
I can't solve the bug on the end of Parcel, however I have located the issue. It's because there is a loader depending on environment with react-pixi.
The code for the initial file is:
module.exports = require(
./dist/react-pixi.cjs${process.env.NODE_ENV === 'development' ? '-dev' : ''})
This means it looks inside it's local node_modules and finds the right file. Of course, once bundled these do not exist. The solution for me was:
import { Stage, Sprite } from '@inlet/react-pixi/dist/react-pixi.cjs'
Instead of:
import { Stage, Sprite } from '@inlet/react-pixi'
I don't think this is the responsibility of bundlers like parcel or webpack to deal with, but is more a problem with the library.
The right approach would probably be something like this:
if (process.env.NODE_ENV === βdevelopment) {
Module.exports = require(...-dev.cjs)
} else {
Module.exports = require(....cjs)
}
I think both the non standard extension and dynamic require cause issues
Sent with GitHawk
Hi, i dont use more this framework, i leave the project, maybe in the future take back the project!
Hi, i have a problem when i try to use parcel and @inlet/react-pixi .
π bug report
When parcel finish the build in the browser i found:
Uncaught Error: Cannot find module './dist/react-pixi.module-dev' at newRequire (src.a2b27638.js:39) at localRequire (src.a2b27638.js:55) at Object.parcelRequire.node_modules/@inlet/react-pixi/module.js (module.js:1) at newRequire (src.a2b27638.js:49) at localRequire (src.a2b27638.js:55)
π Configuration (.babelrc, package.json, cli command)
π― Current Behavior
When the application is building not found the module of react-pixi
π Possible Solution
I think that the solution is put a new way to write:
import { Stage, Sprite } from '@inlet/react-pixi'
π» Code Sample
import { Stage, Sprite } from '@inlet/react-pixi'
π Your Environment
"@inlet/react-pixi": "^0.2.0", "@material-ui/core": "latest", "pixi.js": "^4.8.2", "react": "^16.5.2", "react-dom": "latest", "parcel-bundler": "latest"