CodeKit icon indicating copy to clipboard operation
CodeKit copied to clipboard

url undefined when importing module - pass Prefer-Built-Ins: false || true

Open heaversm opened this issue 5 years ago • 2 comments

Quick, short summary:

I am attempting to import the npm module pixi.js. As soon as I do, I get the compilation error:

Bundled successfully, but with warnings: preferring built-in module 'url' over local alternative at '/node_modules/url/url.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.

When I refresh the browser, I get the console error:

`Uncaught ReferenceError: url is not defined` from PIXI, of which the node module `url` appears to be a dependency.

I am unsure of where or how to pass the `preferBuiltins` option with respect to codekit (or whether this will indeed solve my problem).

Expected results:

ability to import pixi.js via import * as PIXI from 'pixi.js' and have codekit bundle my javascript without error.

Actual results:

Console error in the browser, page does not load.

Exact steps to reproduce:

  • Click on the cloud/download icon in codekit
  • Type pixi.js into the search field
  • Install the module via codekit
  • In your javascript code, type import * as PIXI from 'pixi.js (my file is called main.js)
  • Set the following options within codekit for main.js:
    • ES6 bundle format: IIFE
    • Check minify the output
    • For "When this file changes", "compile it"
  • Make sure your html page is loading the codekit-minified script
  • View the console - see the error mentioned above:

Uncaught ReferenceError: url is not defined

A link to download a simplified project or file that shows the issue:

Your configuration (any details about your system that you think might be relevant)

Screen Shot 2020-07-08 at 4 10 10 PM Screen Shot 2020-07-08 at 4 10 16 PM Screen Shot 2020-07-08 at 4 10 42 PM

heaversm avatar Jul 08 '20 23:07 heaversm

The useBuiltIns option is not currently exposed in the UI but I can do that for the next update.

bdkjones avatar Jul 13 '20 23:07 bdkjones

Actually, this IS exposed in the UI. It's under Babel because the option is related to transpiling and not bundling. false is the default value. Have you changed that?

bdkjones avatar Jul 15 '20 06:07 bdkjones