Skip to content

Commit

Permalink
chore(esbuild): rm inline graceful-fs in dev-server
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduy1407 committed Apr 23, 2024
1 parent 67d0d2a commit b5bf398
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
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, `Rindo 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

0 comments on commit b5bf398

Please sign in to comment.