Skip to content
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

Metacar module should not bind to window object #29

Open
abaybektursun opened this issue Sep 10, 2018 · 0 comments
Open

Metacar module should not bind to window object #29

abaybektursun opened this issue Sep 10, 2018 · 0 comments

Comments

@abaybektursun
Copy link

The dist version of the module metacar.min.js looks like this:

window.metacar=function(t) {

This can be easily solved by changing the libraryTarget in webpack.config.js

var packageConfig = Object.assign({}, config, {
    output: {
        filename: 'metacar.min.js',
        path: path.resolve(__dirname, './dist'),
        library: 'metacar',
        libraryTarget: 'window', 

From libraryTarget: 'window' to libraryTarget: 'commonjs'. Having window object as a target is a problem because for example it is not accessible from Web Workers.

However, there is still another issue: Pixi.js. First of all, it's in externals it really should be bundled with the module. Second of all, Metacar tries to use pixi during the import. Is pixi just used for rendering or is it core part of the game? If it is used just for rendering this problem can be solved be having two separate modes: 1. Simulations 2. Rendering. During the simulation rendering libraries should not be touched. If Pixi lies in the core of the the simulation, you can use jsdom + canvas, node-pixi, or pixi-shim to prevent it from accessing DOM during stimulation. more info: pixijs/pixijs#4771

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant