kit icon indicating copy to clipboard operation
kit copied to clipboard

ssr.noExternal doesn't work with every package

Open tylkomat opened this issue 3 years ago • 0 comments

Describe the bug

As per @benmccann's advice in #5849 I'm providing repo to show that ssr.noExternal fails in some cases and creates a broken built.

Building and running the provided repo results in the following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'context' imported from ...\no-external-test-prod\server\entries\endpoints\index.ts.js

Reproduction

The repo can be pulled from here: https://github.com/tylkomat/no-external-test. While I was talking about prisma in the previous discussion, this was easier to setup.

adapter-node is configured to build into a sibling folder (../no-external-test-prod) to simulate copying the data to the server, when you run npm run build.

Logs

PS ...\no-external-test> npm run build

> [email protected] build
> vite build

Omitting environment variable "COMMONPROGRAMFILES(X86)" from $env/static/private as it is not a valid identifier
Omitting environment variable "PROGRAMFILES(X86)" from $env/static/private as it is not a valid identifier
vite v3.0.5 building for production...
✓ 14 modules transformed.
.svelte-kit/output/client/manifest.json                                   1.22 KiB
.svelte-kit/output/client/_app/immutable/layout.svelte-add7c5d7.js        0.53 KiB / gzip: 0.35 KiB
.svelte-kit/output/client/_app/immutable/error.svelte-a71bdff9.js         1.56 KiB / gzip: 0.75 KiB
.svelte-kit/output/client/_app/immutable/pages/index.svelte-b1b150f9.js   1.33 KiB / gzip: 0.72 KiB
.svelte-kit/output/client/_app/immutable/chunks/index-03969575.js         6.85 KiB / gzip: 2.80 KiB
.svelte-kit/output/client/_app/immutable/start-638c390d.js                24.04 KiB / gzip: 9.05 KiB
vite v3.0.5 building SSR bundle for production...
✓ 49 modules transformed.
Generated an empty chunk: "hooks"
.svelte-kit/output/server/manifest.json                             1.25 KiB
.svelte-kit/output/server/index.js                                  78.04 KiB
.svelte-kit/output/server/entries/endpoints/index.ts.js             114.25 KiB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js        0.25 KiB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js         0.74 KiB
.svelte-kit/output/server/entries/pages/index.svelte.js             0.79 KiB
.svelte-kit/output/server/_app/immutable/chunks/index-3e01a4ca.js   2.61 KiB
.svelte-kit/output/server/_app/immutable/chunks/hooks-bced8853.js   0.00 KiB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-node
  ✔ done
PS ...\no-external-test> cp .\package.json ..\no-external-test-prod\
PS ...\no-external-test> node ..\no-external-test-prod\
Listening on 0.0.0.0:3000
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'context' imported from ...\no-external-test-prod\server\entries\endpoints\index.ts.js
    at new NodeError (node:internal/errors:387:5)
    at packageResolve (node:internal/modules/esm/resolve:909:9)
    at moduleResolve (node:internal/modules/esm/resolve:958:20)
    at defaultResolve (node:internal/modules/esm/resolve:1173:11)
    at nextResolve (node:internal/modules/esm/loader:173:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:852:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:439:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36)


### System Info

```shell
System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 3.98 GB / 15.93 GB
  Binaries:
    Node: 18.7.0 - ~\AppData\Local\Volta\tools\image\node\18.7.0\node.EXE
    npm: 8.15.0 - ~\AppData\Local\Volta\tools\image\node\18.7.0\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (104.0.1293.47)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-node: ^1.0.0-next.86 => 1.0.0-next.86
    @sveltejs/kit: next => 1.0.0-next.405
    svelte: ^3.44.0 => 3.49.0
    vite: ^3.0.0 => 3.0.5

Severity

annoyance

Additional Information

No response

tylkomat avatar Aug 10 '22 09:08 tylkomat