Skip to content

Missing "./package.json" export in "d3-scale" package (and others) #3053

@techniq

Description

@techniq

Describe the bug

After upgrading my LayerChart visualization component library to SvelteKit 1.0.0-next.202 which includes Vite 2.7, I now receive a bunch of the following errors on startup for many d3 packages (d3-scale, d3-shape, d3-array, d3-time)...

12:29:01 PM [vite] Internal server error: Missing "./package.json" export in "d3-scale" package
  Plugin: vite:import-analysis
  File: /home/projects/sveltekit-gw2gco/node_modules/layercake/src/settings/defaultScales.js
      at bail (/home/projects/sveltekit-gw2gco/node_modules/vite/dist/node/chunks/dep-7817f5b4.js:29925:8)
      at resolve (/home/projects/sveltekit-gw2gco/node_modules/vite/dist/node/chunks/dep-7817f5b4.js:29978:7)
      at resolveExports (/home/projects/sveltekit-gw2gco/node_modules/vite/dist/node/chunks/dep-7817f5b4.js:30625:12)
      at resolveDeepImport (/home/projects/sveltekit-gw2gco/node_modules/vite/dist/node/chunks/dep-7817f5b4.js:30641:26)
      at tryNodeResolve (/home/projects/sveltekit-gw2gco/node_modules/vite/dist/node/chunks/dep-7817f5b4.js:30424:20)
      at viteResolve (/home/projects/sveltekit-gw2gco/node_modules/vite/dist/node/chunks/dep-7817f5b4.js:67443:26)
      at Function.eval [as _resolveFilename] (/home/projects/sveltekit-gw2gco/node_modules/vite/dist/node/chunks/dep-7817f5b4.js:67459:20)
      at Function.requireRelative.resolve (/home/projects/sveltekit-gw2gco/node_modules/require-relative/index.js:30:17)
      at resolveViaPackageJsonSvelte (file:///home/projects/sveltekit-gw2gco/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1160:55)
      at Context.resolveId (file:///home/projects/sveltekit-gw2gco/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1491:26)

What's very perplexing is I didn't have this issue last night and even deployed multiple times via Vercel without any issues.

Based on the error, it seems like the proper fix would be to update all d3 packages (ex. d3-scale) and add ./package.json to exports, although I'm not sure I'm up for PR'ing 50+ packages and how long it would take to get reviewed / merged / released. I also want to make sure its truly required as well :).

I'm also having trouble limiting the example below LayerChart (installing / importing either LayerCake (which LayerChart is built upon) or d3-scale does not throw the error. LayerChart also uses my svelte-ux component library which has some d3 references so I don't know if it's a transitive issue.


While writing this I just realized svelte-ux has the same issue, and is similar that it worked last night and deployed to Vercel multiple times.

Reproduction

Here are 2 StackBlitz reproductions for each project:

Logs

No response

System Info

System:
    OS: macOS 12.0.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 263.47 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - /usr/local/bin/node
    npm: 8.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 96.0.4664.110
    Edge: 96.0.1054.57
    Firefox: 94.0.2
    Safari: 15.1
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.22 => 1.0.0-next.22 
    @sveltejs/kit: ^1.0.0-next.202 => 1.0.0-next.202 
    svelte: ^3.44.3 => 3.44.3

Severity

blocking an upgrade

Additional Information

Related?

Some related discussions with mhkeller in LayerCake (see referenced issues/PRs as well)

Metadata

Metadata

Assignees

No one assigned

    Labels

    p1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.vite

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions