question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to yarn/npm link pixi.js into a webpack

See original GitHub issue

This is not a bug request as such but is for anyone else who ends up searching the issues for a solution to this.

When you yarn link or npm link pixi.js into a webpack built application you will likely come across the error:

Cannot read property ‘start’ of undefined

This is because of the way node_modules are handled in the monorepo. Where each package contains a node_modules folder which symlinks to the other packages in the monorepo it requires. Because each package ends up with its own symlink webpack loads each import for each module again (depending on your webpack symlink following rules).

The simplest solution I found to this is adding the following resolve.alias config to webpack:

{ '@pixi': 'pixi.js/node_modules/@pixi' }

This tells webpack to route any @pixi/* import to the node_modules in bundles/pixi.js which contains all the dependencies except @pixi/jsdoc-template so if you need that you will need to add another rule for that.

Note: This could be resolved in pixi.js by using yarn workspaces to manage the pixi.js monorepo which hoist monorepo imports to top level node_modules to prevent this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ShukantPalcommented, Apr 9, 2020

@bigtimebuddy I didn’t see this problem per say. My local template’s Webpack config is:

const HtmlWebPackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');

module.exports = {
    mode: 'development',
    entry: './src/index.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'app.bundle.js',
    },
    module: {
        rules: [
            {
                test: /\.(js)$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                },
            },
            {
                test: /\.html$/,
                use: [
                    {
                        loader: 'html-loader',
                    },
                ],
            },
            {
                test: /\.jpeg$/,
                use: {
                    loader: 'file-loader',
                },
            },
        ],
    },
    plugins: [
        new HtmlWebPackPlugin({
            template: './src/index.html',
            filename: './index.html',
        }),
        new CopyWebpackPlugin([{
            from: './src/assets', to: './assets',
        }]),
    ],
    watchOptions: {
        aggregateTimeout: 300,
        ignored: ['/node_modules/(?!pixi.js)/'],
    },
};

I don’t see anything special here.

0reactions
stale[bot]commented, Aug 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to yarn/npm link pixi.js into a webpack #6530 - GitHub
This tells webpack to route any @pixi/* import to the node_modules in bundles/pixi.js which contains all the dependencies except @pixi/jsdoc- ...
Read more >
Getting Started with Pixi.js and webpack - James Kiefer
Using webpack and Pixi.js together is very simple. This post should help someone who is new to both but experienced in javascript get...
Read more >
Pixi npm. Pixi. In the basic useage example ( https://www. Any ...
All your incoming assets can be loaded and handled by PixiJS. x branch. js 构建爆炸 ... Basic experience with yarn/npm/Webpack and hands-on experience...
Read more >
How To Set Up PixiJS v5 Project With NPM and Webpack
PixiJS v5. First of all let's look at the usual way of importing PixiJS. After npm i pixi.js. I got following in ......
Read more >
[Fixed] NPM conflicting peer dependency error
Lets consider a scenario of using webpack and compression-webpack-plugin in our project. We currently have the following versions dependencies ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found