pixijs / pixi-projection

MIT License
190 stars 34 forks source link

Importing the plugin (webpack) #110

Closed voglervoice closed 2 years ago

voglervoice commented 2 years ago

Hello! Via npm, I have installed :

"pixi-projection": "^0.4.4",
"pixi.js": "^6.5.3",

I am trying to import the plugin in my files (I have no issues with PIXI alone) :

import * as PIXI from 'pixi.js';
import 'pixi-projection';

But I got this error : export 'projection' (imported as 'PIXI') was not found in 'pixi.js' for new PIXI.projection.Sprite2s

I tried to do

import * as PIXI from 'pixi.js';
window.PIXI = PIXI;
import 'pixi-projection';

and I tried

plugins: [
    new webpack.ProvidePlugin({
      PIXI: 'pixi.js',
    }),

in my webpack config but I am still getting the same error.

What am I missing ? Thanks a lot !

voglervoice commented 2 years ago

I managed to use pixi-projection by importing the classes directly from the .es file :

import * as PIXI from 'pixi.js';
import { Sprite2s } from '../thirdparty/pixi-projection.es';
ivanpopelyshev commented 2 years ago

does import { Sprite2s } from 'pixi-projection' work ?

voglervoice commented 2 years ago

Yes! I should have done that directly. So it's here if someone is having the same issue ;) Thanks

ivanpopelyshev commented 2 years ago

That's usual different between legacy UMD and new es6 module architecture. Previously it was library.module.Class , here its import { Class } from 'library-module'