Sveltejs with Paged.js

Hello

I’m trying to use Paged.js in Sveltekit. And to do this I’m trying to follow some example code of doing a similar objective but using Reactjs.

I’m trying to import pagedjs using:

import { Previewer, registerHandlers, Handler } from 'pagedjs';

However, I"m running into this issue - https://github.com/vitejs/vite/issues/1488

The stacktrace, if it helps, is:


 > node_modules/vite/dist/node/chunks/dep-be032392.js:30265:10: error: [plugin: vite:dep-scan] Failed to resolve entry for package "pagedjs". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "pagedjs". The package may have incorrect main/module/exports specified in its package.json.
    30265 │     throw new Error(`Failed to resolve entry for package "${id}". ` +
          ╵           ^
    at packageEntryFailure (/home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:30265:11)
    at resolvePackageEntry (/home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:30261:9)
    at tryNodeResolve (/home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:30036:11)
    at Context.resolveId (/home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:29896:28)
    at Object.resolveId (/home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:42356:55)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async resolve (/home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:42547:26)
    at async /home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:42669:34
    at async callback (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:832:28)
    at async handleRequest (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:664:30)

   node_modules/vite/dist/node/chunks/dep-be032392.js:42659:18: note: This error came from the "onResolve" callback registered here
    42659 │             build.onResolve({
          ╵                   ~~~~~~~~~
    at setup (/home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:42659:19)
    at handlePlugins (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:756:23)
    at Object.buildOrServe (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:1044:7)
    at /home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:1895:17
    at new Promise (<anonymous>)
    at Object.build (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:1894:14)
    at Object.build (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:1749:51)
    at /home/anton/git/language-learner/my-book/node_modules/vite/dist/node/chunks/dep-be032392.js:42506:54
    at Array.map (<anonymous>)

   html:/home/anton/git/language-learner/my-book/src/routes/index.svelte:6:54: note: The plugin "vite:dep-scan" was triggered by this import
        6 │   import { Previewer, registerHandlers, Handler } from 'pagedjs';
          ╵                                                        ~~~~~~~~~

> Build failed with 1 error:
node_modules/vite/dist/node/chunks/dep-be032392.js:30265:10: error: [plugin: vite:dep-scan] Failed to resolve entry for package "pagedjs". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "pagedjs". The package may have incorrect main/module/exports specified in its package.json.
Error: Build failed with 1 error:
node_modules/vite/dist/node/chunks/dep-be032392.js:30265:10: error: [plugin: vite:dep-scan] Failed to resolve entry for package "pagedjs". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "pagedjs". The package may have incorrect main/module/exports specified in its package.json.
    at failureErrorWithLog (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:1493:15)
    at /home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:1151:28
    at runOnEndCallbacks (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:941:63)
    at buildResponseToResult (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:1149:7)
    at /home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:1258:14
    at /home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:629:9
    at handleIncomingPacket (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/home/anton/git/language-learner/my-book/node_modules/esbuild/lib/main.js:596:7)
    at Socket.emit (events.js:376:20)
    at Socket.emit (domain.js:470:12)

Any help is greatly appreciated.

Hi there!

Thanks!

We’re gonna have a look and we’ll probably add the src in the published version.
Our main dev is away for a couple of weeks, but this should happen soon.

Thanks Julien, this is greatly appreciated

you’re welcome!

I’m curious about vite.js seems a pretty interresting tool!