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

double-imported esm and cjs modules in the esbuild dist for RapiD #492

Closed
Bonkles opened this issue Jul 7, 2022 · 2 comments
Closed

double-imported esm and cjs modules in the esbuild dist for RapiD #492

Bonkles opened this issue Jul 7, 2022 · 2 comments
Assignees
Labels
chore Improvements to the code or development stack, cleanups

Comments

@Bonkles
Copy link
Contributor

Bonkles commented Jul 7, 2022

Here's a view of the docs/statistics page currently:

Image

All the pixi modules are double-imported, once for ecma script modules (ESM) and once for commonJS (CJS). This leads to a very large bundle size, because we're effectively importing the entirety of pixi twice. Need to investigate why this is.

@Bonkles Bonkles self-assigned this Jul 7, 2022
@Bonkles
Copy link
Contributor Author

Bonkles commented Jul 7, 2022

Some google-fu resulted in this page: evanw/esbuild#1950, I will be using it as a template to investigate this issue too.

After turning on 'logLevel: verbose' mode in the esbuild.config.js file, performing a build with node config/esbuild.config.modern.js, and observing the output in a terminal window, I searched for dist/cjs/pixi.js in the output and got the following block:

Read 3 entries for directory
  "/Users/clarkben/working/RapiD/node_modules/pixi-dashed-line/dist"
  No "browser" map found in directory
  "/Users/clarkben/working/RapiD/node_modules/pixi-dashed-line/dist"
  Searching for "pixi.js" in "node_modules" directories starting from
  "/Users/clarkben/working/RapiD/node_modules/pixi-dashed-line/dist"
    Parsed package name "pixi.js" and package subpath "."
    Checking for a package in the directory
  "/Users/clarkben/working/RapiD/node_modules/pixi.js"
    Read 5 entries for directory
  "/Users/clarkben/working/RapiD/node_modules/pixi.js"
    Looking for "." in "exports" map in
  "/Users/clarkben/working/RapiD/node_modules/pixi.js/package.json"
      Using the entry for "."
      Checking condition map for one of ["browser", "default", "require"]
        The key "import" does not apply
        The key "require" applies
        Checking condition map for one of ["browser", "default", "require"]
          The key "types" does not apply
          The key "default" applies
          Checking path "" against target "./dist/cjs/pixi.js"
            Joined "" to "./dist/cjs/pixi.js" to get "./dist/cjs/pixi.js"
      The resolved path
  "/Users/clarkben/working/RapiD/node_modules/pixi.js/dist/cjs/pixi.js" is exact
      Read 3 entries for directory
  "/Users/clarkben/working/RapiD/node_modules/pixi.js/dist"
      Read 4 entries for directory
  "/Users/clarkben/working/RapiD/node_modules/pixi.js/dist/cjs"
      Resolved to
  "/Users/clarkben/working/RapiD/node_modules/pixi.js/dist/cjs/pixi.js"
  Read 4 entries for directory
  "/Users/clarkben/working/RapiD/node_modules/pixi.js/dist/cjs"
  Primary path is
  "/Users/clarkben/working/RapiD/node_modules/pixi.js/dist/cjs/pixi.js" in
  namespace "file"

This pretty clearly shows that the pixi-dashed-line module is what is picking up all the .cjs modules. When I comment out all the usage of this particular module (it's only used for drawing halos around hovered features, so this wasn't too difficult- 3 or 4 files) the build stats go back to normal:

Image

@Bonkles
Copy link
Contributor Author

Bonkles commented Oct 20, 2022

Fixed in 8b3761b while upgrading to v7.

In the course of upgrading to v7, I decided to wholly gobble up the pixi-dashed-line repo and rehost / rebuild it with our country-coder techniques as the last release was well over a year ago and there has been no movement on the original repo.

The new repo is at https://github.com/Bonkles/pixi-dashed-line.

This had the added benefit of driving out the double dependencies!

@Bonkles Bonkles closed this as completed Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Improvements to the code or development stack, cleanups
Projects
Status: 🏁 Done
Development

No branches or pull requests

1 participant