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

Vercel Build Fails as Can't Set EsBuild Externals #3588

Closed
cryptodeal opened this issue Jan 28, 2022 · 4 comments · Fixed by #3614
Closed

Vercel Build Fails as Can't Set EsBuild Externals #3588

cryptodeal opened this issue Jan 28, 2022 · 4 comments · Fixed by #3614

Comments

@cryptodeal
Copy link

cryptodeal commented Jan 28, 2022

Describe the bug

My vercel build has been failing since the removal of the esBuild config options in @sveltejs/adapter-vercel.

I've continued developing using the following package versions (last working):

"@sveltejs/adapter-vercel": "1.0.0-next.32",
"@sveltejs/kit": "1.0.0-next.206",

However, that's definitely less than ideal as I'm continuing to build around an outdated API for both @sveltejs/kit & @sveltejs/adapter-vercel.

The dependency causing my build issues (@napi-rs/*) is a package required indirectly as a dependency of a package in a shared monorepo used in the frontend. (Backend defines db schema, controllers, autogen type definitions, etc. that are used both in the frontend and for writing real time data scraped from various sources to the db, hence the monorepo greatly streamlines the dev process).

I'd previously built the frontend project successfully using both Vite resolve.alias and via installing the pnpm symlinked version of the built package as a dependency during the build process (setting pnpm to shamefully-hoist when building on Vercel) using the following esBuild config options:

adapter({
  esbuild(defaultOptions) {
    return {
      ...defaultOptions,
      plugins: [],
      external: ['@napi-rs/*']
    };
  }
})

Following the breaking API changes, I've tested with updated versions of @sveltejs/kit & @sveltejs/adapter-vercel using at least the following Vite config settings (both individually and in varying combinations), but to no avail.

Vite Config Options Tested:

  vite.ssr.noExternal: ['@napi-rs/*']
  ssr.external:  ['@napi-rs/*']
  vite.optimizeDeps.exclude: ['@napi-rs/*']

(I think I'd tried setting it as a rollup external as well using Vite config options, but that also failed to resolve the issue)

Build always fails with the following error:

error: No loader is configured for ".node" files

Any solutions for getting this build to work with the latest versions of @sveltejs/kit and @sveltejs/adapter-vercel?

Reproduction

I'm more than happy to setup a minimal reproduction of the issue if necessary, but iirc this is something @Rich-Harris is aware of per the checklist in PR #2931.

Logs

No response

System Info

System:
    OS: macOS 12.1
    CPU: (8) arm64 Apple M1
    Memory: 138.94 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.4.2 - ~/.nvm/versions/node/v16.4.2/bin/node
    Yarn: 1.22.11 - /opt/homebrew/bin/yarn
    npm: 7.18.1 - ~/.nvm/versions/node/v16.4.2/bin/npm
  Browsers:
    Brave Browser: 97.1.34.81
    Safari: 15.2
  npmPackages:
    @sveltejs/adapter-vercel: 1.0.0-next.32 => 1.0.0-next.32 
    @sveltejs/kit: 1.0.0-next.206 => 1.0.0-next.206 
    svelte: ^3.46.2 => 3.46.2

Severity

blocking an upgrade

Additional Information

No response

@cryptodeal cryptodeal mentioned this issue Jan 28, 2022
22 tasks
@cryptodeal
Copy link
Author

Related: #3306

@Rich-Harris
Copy link
Member

Would an API like this work?

import adapter from '@sveltejs/adapter-vercel';

export default {
  adapter: adapter({
    external: ['@napi-rs/*']
  }),
  // ...
};

@cryptodeal
Copy link
Author

cryptodeal commented Jan 28, 2022

@Rich-Harris, that should definitely resolve the issue!

@harlantwood
Copy link

harlantwood commented Apr 2, 2022

I was struggling with the same issue in adapter-cloudflare -- eventually found out it has a similar API:

import adapter from '@sveltejs/adapter-cloudflare'

const config = {
  kit: {
    adapter: adapter({
      external: ['redis'],
    }),
  }
}

Note that external: ['redis/*'] did not work.

Posting here for others who may be searching for this info.

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

Successfully merging a pull request may close this issue.

3 participants