Skip to content

[BUG] Imports not being properly deprefixed from npm: #640

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

Open
aleksasiriski opened this issue Jul 8, 2024 · 5 comments
Open

[BUG] Imports not being properly deprefixed from npm: #640

aleksasiriski opened this issue Jul 8, 2024 · 5 comments
Labels
publishing Problems with publishing

Comments

@aleksasiriski
Copy link

aleksasiriski commented Jul 8, 2024

I'm building a SvelteKit adapter and am trying to publish it on jsr.io, is uses two imports:

Both of those when uploaded to jsr.io get changed to:

Only the esbuild one when pulled via pnpm dlx jsr add @hearchco/sveltekit-adapter-aws gets changed back to original:

  • image
  • image

This is causing my SvelteKit built to error out with,  and if I manually change it to original in the node_modules the build is successful:

> Using sveltekit-adapter-aws
✘ [ERROR] Could not resolve "npm:@sveltejs/kit@^2.5.18/node/polyfills"

    .svelte-kit/sveltekit-adapter-aws/server/lambda-handler/index.js:5:33:
      5 │ import { installPolyfills } from 'npm:@sveltejs/kit@^2.5.18/node/polyfills';
        ╵                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "npm:@sveltejs/kit@^2.5.18/node/polyfills" as external to exclude it from
  the bundle, which will remove this error and leave the unresolved path in the bundle.

error during build:
Error: Build failed with 1 error:
.svelte-kit/sveltekit-adapter-aws/server/lambda-handler/index.js:5:33: ERROR: Could not resolve "npm:@sveltejs/kit@^2.5.18/node/polyfills"
    at failureErrorWithLog (/var/home/aleksa/Documents/Projects/Personal/Hearchco/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1472:15)
    at /var/home/aleksa/Documents/Projects/Personal/Hearchco/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:945:25
    at /var/home/aleksa/Documents/Projects/Personal/Hearchco/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:897:52
    at buildResponseToResult (/var/home/aleksa/Documents/Projects/Personal/Hearchco/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:943:7)
    at /var/home/aleksa/Documents/Projects/Personal/Hearchco/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:970:16
    at responseCallbacks.<computed> (/var/home/aleksa/Documents/Projects/Personal/Hearchco/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:622:9)
    at handleIncomingPacket (/var/home/aleksa/Documents/Projects/Personal/Hearchco/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:677:12)
    at Socket.readFromStdout (/var/home/aleksa/Documents/Projects/Personal/Hearchco/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:600:7)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12)
 ELIFECYCLE  Command failed with exit code 1.
@github-project-automation github-project-automation bot moved this to Needs Triage in JSR Jul 8, 2024
@lucacasonato
Copy link
Member

You can workaround this by specifying handler as one of the exports in your jsr.json.

@aleksasiriski
Copy link
Author

Since "handler" is a adapter for SvelteKit it "imports" some files that don't exist in the repo but will exist after being copied into the SvelteKit build folder, and this breaks publishing on JSR: https://github.com/hearchco/sveltekit-adapter-aws/actions/runs/9910061704/job/27379574375#step:7:10

@lucacasonato
Copy link
Member

Ah I see - then for the moment, as a workaround, you can try renaming the file to handler/index.js.txt (no .js file extension). This will stop the rewriting from happening at all.

Definitely a bug during publishing on our side.

@aleksasiriski
Copy link
Author

Hmm, but then I would need to rename it back to .js for SvelteKit to to use properly? I think it's better to wait for the fix instead of using workarounds :) If you point me in the right direction I would be happy to look at this codebase and try to find and fix the bug.

@aleksasiriski
Copy link
Author

Any updates on this?

@crowlKats crowlKats removed the bug label Jan 16, 2025
@crowlKats crowlKats moved this from Needs Triage to Ready in JSR Jan 16, 2025
@crowlKats crowlKats added the publishing Problems with publishing label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
publishing Problems with publishing
Projects
Status: Ready
Development

No branches or pull requests

4 participants