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

puzzling issue with svelte/rollup upgrade #12

Open
aeischeid opened this issue Dec 28, 2020 · 2 comments
Open

puzzling issue with svelte/rollup upgrade #12

aeischeid opened this issue Dec 28, 2020 · 2 comments

Comments

@aeischeid
Copy link

Upgrading a some dependencies in a svelte app where this persistent store was working. I haven't pinned down the precise culprit, my hunch/guess is rollup-plugin-node-resolve

  "devDependencies": {
    "cypress": "^6.2.0",
    "npm-run-all": "^4.1.5", -> (removed)
    "rollup": "^2.23.1" -> "rollup": "^2.35.1",
    "rollup-plugin-commonjs": "^10.1.0", -> "@rollup/plugin-commonjs": "^17.0.0",
    "rollup-plugin-node-resolve": "^5.2.0", -> "@rollup/plugin-node-resolve": "^11.0.0",
    "rollup-plugin-css-only": "^3.1.0",
    "rollup-plugin-livereload": "^1.3.0", -> "rollup-plugin-livereload": "^2.0.0",
    "rollup-plugin-svelte": "^5.2.3", -> "rollup-plugin-svelte": "^7.0.0",
    "rollup-plugin-terser": "^6.1.0", -> "rollup-plugin-terser": "^7.0.0",
    "sirv-cli": "^1.0.8", -> "sirv-cli": "^1.0.10",
    "svelte": "^3.29.4" -> "svelte": "^3.31.0"
  },

but for some reason I was getting an error at startup.

bundles src/main.ts → public/build/bundle.js...
[!] Error: Could not load /path/to/project/node_modules/svelte-persistent-store/dist/dist/local (imported by src/store.js): ENOENT: no such file or directory, open '/path/to/project/node_modules/svelte-persistent-store/dist/dist/local'

I was able to solve by changing my import from

import { writable } from 'svelte-persistent-store/dist/local';

to

import { writable } from 'svelte-persistent-store/local.js';
@Maggi64
Copy link

Maggi64 commented Jan 2, 2021

Downgrading to @rollup/plugin-node-resolve 10.0 also resolves the issue.

@geigerzaehler
Copy link

I believe that the rollup plugin behaves correctly because it respects ECMAScript modules. svelte-persitent-store sets the exports field in package.json. When importing the package as an ECMAScript module all paths svelte-persistent-store/foo/bar are rewritten to svelte-persistent-store/dist/foo/bar.

In theory it should now be possible to import from 'svelte-persistent-store/local'. But unfortunately this does not play well with Typescript because the compiler cannot find the types for svelte-persistent-store/local as it looks for ./node_modules/svelte-persistent-store/local.d.ts. A solution could be to include package type declarations in addition to the module type declarations. Alternatively, the dist directory prefix could be removed in the package archive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants