luzic Posted May 29, 2021 Share Posted May 29, 2021 Hi, I'm getting an error when using pixi.js with rollup. After installing pixi via npm, in the code I do: import * as PIXI from 'pixi.js' I got the following error: [!] Error: 'default' is not exported by node_modules/object-assign/index.js, imported by node_modules/@pixi/polyfill/dist/esm/polyfill.jshttps://rollupjs.org/guide/en/#error-name-is-not-exported-by-module node_modules/@pixi/polyfill/dist/esm/polyfill.js (9:7) 7: */ 8: import Polyfill from 'promise-polyfill'; 9: import objectAssign from 'object-assign'; ^ 10: 11: // Support for IE 9 - 11 which does not include Promises Error: 'default' is not exported by node_modules/object-assign/index.js, imported by node_modules/@pixi/polyfill/dist/esm/polyfill.js at error (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:5400:30) at Module.error (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:9824:16) at handleMissingExport (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:9725:28) at Module.traceVariable (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:10163:24) at ModuleScope.findVariable (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:8770:39) at BlockScope.findVariable (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:3065:38) at Identifier$1.bind (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:4403:40) at AssignmentExpression.bind (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:3152:23) at ExpressionStatement$1.bind (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:3152:23) at BlockStatement$1.bind (/Users/leozcliu/Code/Atlas/node_modules/rollup/dist/shared/node-entry.js:3148:31) Here's my rollup.config.js, it must be missing something? export default [ { input: "src/index.js", output: { file: "dist/myProject.js", name: "myProject", format: "umd" }, plugins: [ resolve() ], onwarn: function (warning, warn) { if (warning.code === 'CIRCULAR_DEPENDENCY') return; warn(warning); } } ]; Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 29, 2021 Share Posted May 29, 2021 Sounds like an actual issue, please report to pixijs github issues and search whether there was one like that Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted June 3, 2022 Share Posted June 3, 2022 (edited) Rollup.js works well for me with JavaScript. Debugging command: rollup -cmw where: -c - create a bundle, -m - debug mode, -w - watch) Release commands: rollup -c uglifyjs public/js/bundle.js -o public/js/bundle.min.js rollup.config.js export default { input: "./src/client/main.js", output: { file: "public/js/bundle.js" } } src/client/main.js import * as PIXI from "pixi.js" const app = new PIXI.Application({ width: window.innerWidth, height: window.innerHeight, backgroundColor: 0x2c3e50 }); document.body.appendChild(app.view); const gr = new PIXI.Graphics(); gr.beginFill(0xffffff); gr.drawCircle(30, 30, 30); gr.endFill(); app.stage.addChild(gr); public/index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> body { margin: 0; } </style> </head> <body> <script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script> <script type="importmap"> { "imports": { "pixi.js": "https://cdn.skypack.dev/[email protected]" } } </script> <script type="module" src="js/bundle.js"></script> </body> </html> Edited June 3, 2022 by 8Observer8 Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted June 3, 2022 Share Posted June 3, 2022 But when I try to use Rollup.js and Pixi.js with TypeScript I get the same error: rollup.config.js import babel from "@rollup/plugin-babel"; import resolve from "@rollup/plugin-node-resolve"; import json from "@rollup/plugin-json"; import filesize from "rollup-plugin-filesize"; const extensions = [".ts"]; const babelOptions = { babelrc: false, extensions, exclude: "**/node_modules/**", babelHelpers: "bundled", presets: [ [ "@babel/preset-env", { loose: true, modules: false, targets: ">1%, not dead, not ie 11, not op_mini all", }, ], "@babel/preset-typescript", ], }; export default { input: "./src/main.ts", output: { file: "public/js/bundle.js" }, plugins: [ json(), resolve({ extensions }), babel(babelOptions), filesize() ] } src/main.ts import * as PIXI from "pixi.js" const app = new PIXI.Application({ width: window.innerWidth, height: window.innerHeight, backgroundColor: 0x2c3e50 }); document.body.appendChild(app.view); const gr = new PIXI.Graphics(); gr.beginFill(0xffffff); gr.drawCircle(30, 30, 30); gr.endFill(); app.stage.addChild(gr); public/index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script src="js/bundle.js"></script> </body> </html> Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 4, 2022 Share Posted June 4, 2022 Please ask in github or in our discord, because build-tools people arent usually watching the forum. https://discord.gg/s6SCfj2S27 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.