-
Notifications
You must be signed in to change notification settings - Fork 57
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
Unable to import #48
Comments
I even tried to tweak the compiler options, but no luck, it still doesn't export anything... everything is hidden behind namespace without any module export...
|
Does import * as PIXI from 'pixi.js' work? Place it before importing pixi-layers. |
I'll add it to README.
sometimes Here's the demo that works: https://codesandbox.io/s/tender-franklin-iycmu , look in |
Doesn't work with rollup. If deferred to get PIXI actually into window, PIXI object there becomes frozen. |
Here is cheap workaround for module support. First, forking plugin. // top of dist/pixi-layers.js
import * as PIXI from "pixi.js"; When apply workaround above, About known workarounds... |
For those who have this issue here is an implementation of this "cheap" workaround that work for me. in your webpack config:
with this script :
|
If I add that import to the top of dist/pixi-layers.js I get this error when building the app:
I'm not experienced with JS build systems. A friend set it up for me using rollup. |
Still testing but this seems to work:
|
I am getting the |
|
I tried that 👇 <script type="module">
import * as PIXI from 'https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.3.9/pixi.min.js';
window.PIXI = PIXI
import 'https://cdn.jsdelivr.net/npm/pixi-layers@0.3.1/dist/pixi-layers.min.js';
document.addEventListener("DOMContentLoaded", function(event) {
//bunny example from https://pixijs.io/examples/#/plugin-layers/lighting.js
})
</script> this results in
|
imports work before all other code :( need a |
Checking in to see if there is a fix for this yet or a good workaround Currently when I try:
inside a module it gives me the following error:
My understanding is that window.PIXI exists at the time layers is imported. |
Why do you need layers in umd if you use imports? |
Thanks for the quick reply. I was under the impression that the "universal" package was an appropriate package to import. Sounds like I am wrong. I have tried the non umd version
But I get a "ReferenceError: exports is not defined" error. Is there a more appropriate way to dynamically import the layers plugin inside a module? |
I actually dont know how to work with mjs pixi and plugins with usual browser |
Hello there,
both...
require('pixi-layers)
...and...
import {Stage, Layer} from 'pixi-layers', or import * as Layers from 'pixi-layers'
...fails.
Uncaught ReferenceError: PIXI is not defined
I did import PIXI before the import call.
import 'pixi.js'
or import PIXI from 'pixi.js'
I also tried require.
Nothing works... same error. The layers plugin is not compatible with cjs and es imports?
The text was updated successfully, but these errors were encountered: