-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat(adapter-node): support all esbuild build options #1692
Conversation
🦋 Changeset detectedLatest commit: 3ee4efe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
I think it would be more clear if these options were nested under a single |
I have adjusted the PR to use a |
e530e1e
to
dfae928
Compare
Commit message has a typo. |
dfae928
to
8e765d3
Compare
Sorry, I do not know what you mean. |
c6075d7 |
bd65b73
to
9ae2301
Compare
Same thing in the commit message. (Don't know if you will fix it later or overlooked it) |
I can not fix that now. But I believe that PRs are squashed and use the PR title (which is fixed) as commit message. |
Just thought I would raise before we adopt
Has there been more thought on alternative solutions or is |
@jthegedus it's not an area I understand well, so I will defer to Rich and Conduitry |
There's a related PR for |
This PR allows to change the options passed to esbuild build which allows to customize the server generation like target node version, sourcemap, inject and more. It contains one braking change: `out` is renamed to `outdir` to follow the esbuild API. It is possible to avoid a breaking change by making `out` an alias for `outdir`. I'm happy to adjust the PR.
9ae2301
to
3ee4efe
Compare
Done.
I do not know if using Maybe a hybrid approach: {
...config?.kit?.vite()?.esbuild,
...esbuildOptions,
} But that would make reasoning about the resulting config difficult. What is your take on this? |
Is there anything I can do to progress this PR? |
Since the common js output format is also available in this PR. I'm wondering if we can check if __dirname and require already exist before shim it, so the configuring is easier. I tried building it to cjs before and it's throwing an error in the runtime because import.meta.url is undefined. But regarding how to check if var __dirname;
__dirname = __dirname ?? dirname(fileURLToPath(import.meta.url)) (Sorry I spamed the notification. accidently deleted the previous comment) |
I use define + inject:
import { pathToFileURL } from 'url'
export const shim_import_meta_url = /*#__PURE__*/ pathToFileURL(__filename) And the in the esbuild config:
This works quite well for single file outputs. |
I'm also fine with an example in the doc. I just thought making it work out of the box would be a little bit easier for the user. |
Why are you wanting to change |
We are bundling the server and the assets using pkg into an executable. pkg needs cjs as format and we can use a higher target (v16). |
And we're hosting with Windows IIS with iisnode, which doesn't seem to support ESM. People using other hosting platforms that don't already have an official adapter may want to leverage the node adapter. And since some other adapters also ship common js. I think it would a good idea to allow configuring node adapter to output common js. |
@sastan it looks like this PR will need to be rebased |
I agree. It's better to keep them separately configurable |
This PR allows changing the options passed to esbuild build which allows to customize the server generation like target node version, sourcemap, inject, and more.
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts