Skip to content

Commit 086687d

Browse files
committed
fix: potential fix for packaged executable
1 parent bd3a2d1 commit 086687d

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

scripts/build.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const projectPath = path.dirname(
1616

1717
const platform = os.platform();
1818

19+
/**
20+
* This plugin intercepts loading of certain imports and replaces their contents.
21+
* It overrides the import paths for native imports for rocksdb, fd-lock and sodium-native
22+
*/
1923
const nativeNodeModulesPlugin = {
2024
name: 'native-node-modules',
2125
setup(build) {
@@ -124,7 +128,7 @@ async function main(argv = process.argv) {
124128
// This specifies import paths that is left as an external require
125129
// This is kept to packages that have a native binding
126130
/** @type { import('esbuild').BuildOptions } */
127-
const extraOptions = isPkg
131+
const isPkgSwitchedOptions = isPkg
128132
? {
129133
external: [],
130134
format: 'cjs',
@@ -153,14 +157,14 @@ async function main(argv = process.argv) {
153157
bundle: true,
154158
platform: 'node',
155159
outdir: distPath,
156-
treeShaking: false,
160+
treeShaking: true,
157161
// External source map for debugging
158162
sourcemap: true,
159163
// Minify and keep the original names
160164
minify: false,
161165
keepNames: true,
162166
plugins: [nativeNodeModulesPlugin],
163-
...extraOptions,
167+
...isPkgSwitchedOptions,
164168
};
165169
console.error('Running esbuild:');
166170
console.error(esbuildOptions);

scripts/pkg.mjs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,6 @@ async function main(argv = process.argv) {
104104
const pkgConfig = packageJSON.pkg ?? {};
105105
pkgConfig.assets = pkgConfig.assets ?? {};
106106

107-
// //0---
108-
// const nativeAssetDir = path.join(projectPath, 'dist', 'native');
109-
// const nativeAssets = await find(nativeAssetDir, /\.node$/);
110-
111-
// pkgConfig.assets.push(
112-
// ...nativeAssets.map((p) => path.relative(projectPath, p))
113-
// );
114-
// //0---
115-
116107
const npmLsOut = childProcess.execFileSync(
117108
'npm',
118109
['ls', '--all', '--omit=dev', '--parseable'],
@@ -157,7 +148,6 @@ async function main(argv = process.argv) {
157148
'--public',
158149
"--public-packages='*'",
159150
`--output=${outPath}`,
160-
'-d',
161151
...restArgs,
162152
];
163153
console.error('Running pkg:');

0 commit comments

Comments
 (0)