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

bundle with rollup instead of esbuild #6896

Merged
merged 5 commits into from Sep 20, 2022
Merged

Conversation

Rich-Harris
Copy link
Member

Alternative to #6855, which is itself an alternative to #6797.

With this PR, we bundle adapter-node apps with Rollup instead of esbuild. It's slower, but avoids evanw/esbuild#1921 which doesn't look like it'll be fixed any time soon (even though there's a PR — evanw/esbuild#2067), and means that we can deal with both ESM and CJS dependencies without adding more configuration.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Sep 19, 2022

🦋 Changeset detected

Latest commit: ed5cc7b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/adapter-node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sounds like a better plan to me than #6855. it will be slower but will remove lots of headaches

packages/adapter-node/index.js Show resolved Hide resolved
import { rollup } from 'rollup';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the JSON plugin? will people be importing JSON that hasn't already been bundled by Vite?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They could be using a devdependency that includes JSON which isn't bundled yet but which we want to bundle when adapting.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, this needs to work with require('./stuff.json')

@@ -45,6 +45,7 @@
"uvu": "^0.5.3"
},
"dependencies": {
"esbuild": "^0.15.7"
"@rollup/plugin-commonjs": "^22.0.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want these two as dependencies and @rollup/plugin-json in devDependencies? I'd expect them to be in the same place

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, fixed

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

the only other thought I had is whether it might be better to use vite rather than rollup to do the bundling. vite will already be in the user's dependencies, but the rollup plugins will not be, so it could reduce the dependency footprint

@Rich-Harris
Copy link
Member Author

True. I feel like it adds some more moving parts though, since Vite does a lot of stuff on top of what you get with Rollup. With Rollup everything is very straightforward and predictable

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 this pull request may close these issues.

None yet

3 participants