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

chore(esbuild): rm inline graceful-fs in dev-server #5625

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions scripts/esbuild/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { bundleExternal, sysNodeBundleCacheDir } from '../bundles/sys-node';
import { getBanner } from '../utils/banner';
import { type BuildOptions, createReplaceData } from '../utils/options';
import { writePkgJson } from '../utils/write-pkg-json';
import { getBaseEsbuildOptions, getEsbuildAliases, getFirstOutputFile, runBuilds } from './util';
import { externalAlias, getBaseEsbuildOptions, getEsbuildAliases, getFirstOutputFile, runBuilds } from './util';

const CONNECTOR_NAME = 'connector.html';

Expand Down Expand Up @@ -70,9 +70,15 @@ export async function buildDevServer(opts: BuildOptions) {
bundleExternal(opts, opts.output.devServerDir, cachedDir, 'open-in-editor-api.js'),
]);

const devServerAliases = getEsbuildAliases();
const external = [...builtinModules, './ws.js', './open-in-editor-api'];
const external = [
...builtinModules,
// ws.js is externally bundled
'./ws.js',
// open-in-editor-api is externally bundled
'./open-in-editor-api',
];

const devServerAliases = getEsbuildAliases();
const devServerIndexEsbuildOptions = {
...getBaseEsbuildOptions(),
alias: devServerAliases,
Expand Down Expand Up @@ -100,7 +106,12 @@ export async function buildDevServer(opts: BuildOptions) {
format: 'cjs',
platform: 'node',
write: false,
plugins: [esm2CJSPlugin(), contentTypesPlugin(opts), replace(createReplaceData(opts))],
plugins: [
esm2CJSPlugin(),
contentTypesPlugin(opts),
replace(createReplaceData(opts)),
externalAlias('graceful-fs', '../sys/node/graceful-fs.js'),
],
banner: {
js: getBanner(opts, `Stencil Dev Server Process`, true),
},
Expand Down
1 change: 0 additions & 1 deletion scripts/esbuild/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function getEsbuildAliases(): Record<string, string> {
// reference the same file
prompts: './sys/node/prompts.js',
glob: './sys/node/glob.js',
'graceful-fs': './sys/node/graceful-fs.js',

// dev server related aliases
ws: './ws.js',
Expand Down