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

Cleanup esbuildSync and esbuildAsync #276

Open
fwang opened this issue Oct 11, 2023 · 1 comment
Open

Cleanup esbuildSync and esbuildAsync #276

fwang opened this issue Oct 11, 2023 · 1 comment

Comments

@fwang
Copy link
Contributor

fwang commented Oct 11, 2023

They seem identical. Do we need both?

function esbuildSync(esbuildOptions: ESBuildOptions) {
const { openNextVersion, debug } = options;
const result = buildSync({
target: "esnext",
format: "esm",
platform: "node",
bundle: true,
minify: debug ? false : true,
sourcemap: debug ? "inline" : false,
...esbuildOptions,
banner: {
...esbuildOptions.banner,
js: [
esbuildOptions.banner?.js || "",
`globalThis.openNextDebug = ${process.env.OPEN_NEXT_DEBUG ?? false};`,
`globalThis.openNextVersion = "${openNextVersion}";`,
].join(""),
},
});
if (result.errors.length > 0) {
result.errors.forEach((error) => console.error(error));
throw new Error(
`There was a problem bundling ${
(esbuildOptions.entryPoints as string[])[0]
}.`,
);
}
}
async function esbuildAsync(esbuildOptions: ESBuildOptions) {
const { openNextVersion, debug } = options;
const result = await buildAsync({
target: "esnext",
format: "esm",
platform: "node",
bundle: true,
minify: debug ? false : true,
sourcemap: debug ? "inline" : false,
...esbuildOptions,
banner: {
...esbuildOptions.banner,
js: [
esbuildOptions.banner?.js || "",
`globalThis.openNextDebug = ${process.env.OPEN_NEXT_DEBUG ?? false};`,
`globalThis.openNextVersion = "${openNextVersion}";`,
].join(""),
},
});
if (result.errors.length > 0) {
result.errors.forEach((error) => console.error(error));
throw new Error(
`There was a problem bundling ${
(esbuildOptions.entryPoints as string[])[0]
}.`,
);
}
}

@khuezy
Copy link
Collaborator

khuezy commented Oct 11, 2023

we can get rid of the non async one if it doesn't break the build. We had to use async for the plugin system iirc

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

No branches or pull requests

2 participants