-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Blocking bug with @pixi/node, unable to use with non-CommonJS modules #8502
Comments
Another workaround, is to change all the esm packages to have ".mjs" extension instead of ".js". |
I was able to patch exports.import.default on every package and replace .mjs and it worked, but I'm now running into another issue related to ismobilejs:
Here's the offending output: var isMobile = isMobileCall(globalThis.navigator); Replaced with this worked. var isMobile = isMobileCall.default(globalThis.navigator); We need to find a better way to import that dependency, maybe bundling? |
Not sure about the dependency stuff however isMobile is not node friendly, it doesn't know that is running in a backend environment. Maybe |
I'm thinking that ismobilejs is not applicable for this usage. We use it internally most to check for apple or android devices. We might be better served moving it to the Browser and Node adapters instead. I finally got hello world working with mjs, but it required these ugly hacks to fix the above things: These things seem fixable. |
NodeJS requires a I don't know if it's possible to have several EDIT: Looks like it's possible: https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html For each packages, adding a {
"type": "module"
} And a {
"type": "commonjs"
} Seems to be a solution. |
I came across https://antfu.me/posts/publish-esm-and-cjs a while ago when I was running into this issue with a side project I'm working on. The configurations used in the package.json might be helpful here |
I've been experimenting with the
@pixi/node
package available in v6.5.0-rc.2. I have no problems when it's using CommonJS (e.g.,require('@pixi/node')
), but I am having issues using modules (e.g.,import * as PIXI from '@pixi/node'
).Here's a simple example:
https://github.com/bigtimebuddy/pixi-node-example/blob/module/index.mjs
Running this produces the following error:
Having all packages be both CommonJS and ESM seems to confuse Node, even with the proper type. I have not found a way to force dependencies to use modules. Kinda stuck, any ideas?
A workaround would be to bundle everything (except the 3rd party dependencies like canvas, gl, etc) so that it's a single file. Providing cjs and mjs files seems like it would work.
EDIT: think I figured out what needs to happen here:
TODO
exports
to assets (Added exports to package.json in Assets Package #8504)The text was updated successfully, but these errors were encountered: