Skip to content

Commit

Permalink
fix: Remove runtime esbuild dependency (#197)
Browse files Browse the repository at this point in the history
DH-18191: Removed runtime esbuild dependency and move to simpler text
replacement methodology to cut down on memory consumption.
  • Loading branch information
bmingles authored Jan 7, 2025
1 parent 1f42b1d commit 4f186d5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
23 changes: 11 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,7 @@
"dependencies": {
"@deephaven-enterprise/auth-nodejs": "^1.20240723.124-beta",
"@deephaven-enterprise/query-utils": "^1.20240723.124-beta",
"@deephaven/jsapi-nodejs": "0.100.0",
"esbuild-wasm": "^0.24.0",
"@deephaven/jsapi-nodejs": "0.102.0",
"nanoid": "^5.0.7"
},
"devDependencies": {
Expand All @@ -879,6 +878,7 @@
"@wdio/mocha-framework": "^8.39.0",
"@wdio/spec-reporter": "^8.39.0",
"ctrf": "^0.0.9",
"esbuild-wasm": "^0.24.0",
"eslint": "^8.57.0",
"fantasticon": "^3.0.0",
"github-actions-ctrf": "^0.0.20",
Expand Down
Binary file modified releases/vscode-deephaven-latest.vsix
Binary file not shown.
34 changes: 21 additions & 13 deletions src/dh/dhc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,33 @@ export async function getDhc(
storageDir: string
): Promise<typeof DhType> {
// Download jsapi `ESM` files from DH Community server.
const coreModule = await loadModules<{ default: typeof DhType }>({
const coreModule = await loadModules<typeof DhType>({
serverUrl,
serverPaths: ['jsapi/dh-core.js', 'jsapi/dh-internal.js'],
download: true,
download: (serverPath, content) => {
if (serverPath === 'jsapi/dh-core.js') {
return content
.replace(
`import {dhinternal} from './dh-internal.js';`,
`const {dhinternal} = require("./dh-internal.js");`
)
.replace(`export default dh;`, `module.exports = dh;`);
}

if (serverPath === 'jsapi/dh-internal.js') {
return content.replace(
`export{__webpack_exports__dhinternal as dhinternal};`,
`module.exports={dhinternal:__webpack_exports__dhinternal};`
);
}

return content;
},
storageDir,
sourceModuleType: 'esm',
targetModuleType: 'cjs',
esbuildOptions: {
tsconfigRaw: {
compilerOptions: {
// This needs to be set to avoid adding `use strict` to the output
// which hits a protobuf bug. https://github.com/protocolbuffers/protobuf-javascript/issues/8
strict: false,
},
},
},
});

return coreModule.default;
return coreModule;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dh/dhe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function getDhe(
serverPaths: ['irisapi/irisapi.nocache.js'],
download: true,
storageDir,
sourceModuleType: 'cjs',
targetModuleType: 'cjs',
});

// DHE currently exposes the jsapi via the global `iris` object.
Expand Down

0 comments on commit 4f186d5

Please sign in to comment.