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

ESBuild define option can break adapter-node assetsMiddleware #2581

Closed
arnivuo opened this issue Oct 10, 2021 · 0 comments · Fixed by #2931
Closed

ESBuild define option can break adapter-node assetsMiddleware #2581

arnivuo opened this issue Oct 10, 2021 · 0 comments · Fixed by #2931

Comments

@arnivuo
Copy link

arnivuo commented Oct 10, 2021

Describe the bug

I switched from another adapter to use node adapter and had esbuild options with define. That basically overwrites esbuild_app_dir defined by the adapter breaking assetsMiddleware. A symptom is rather odd as all assets are responding to status code 500 with no clue why.

Maybe the adapter should warn the user if they overwrite the esbuild_app_dir property from define or the documentation could mention it. Now you can figure it out but it's not that obvious.

Reproduction

In svelte.config.js configure node adapter like:

adapterNode({
  esbuild(defaultOptions) {
    return {
      ...defaultOptions,
      define: {
        foo: 'bar'
      }
    };
  }
});

Build, run node build and check broken http://localhost:3000 site.

Fix is to do configuration e.g.:

adapterNode({
  esbuild(defaultOptions) {
    defaultOptions.define = {
      ...defaultOptions.define,
      foo: 'bar'
    }
    return defaultOptions;
  }
});

Logs

No response

System Info

System:
    OS: macOS 11.5.2
    CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
    Memory: 63.46 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.1 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.12 - /usr/local/bin/npm
  Browsers:
    Chrome: 94.0.4606.71
    Safari: 14.1.2
  npmPackages:
    @sveltejs/adapter-node: ^1.0.0-next.53 => 1.0.0-next.53
    @sveltejs/adapter-static: ^1.0.0-next.13 => 1.0.0-next.20
    @sveltejs/kit: 1.0.0-next.180 => 1.0.0-next.180
    svelte: ^3.34.0 => 3.43.1

Severity

annoyance

Additional Information

No response

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