@travetto/pack 3.1.0-rc.3 → 3.1.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/support/bin/config.ts +13 -16
- package/support/bin/operation.ts +17 -0
- package/support/pack.base.ts +1 -0
package/package.json
CHANGED
package/support/bin/config.ts
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import type { OutputOptions } from 'rollup';
|
|
2
|
+
import { __importStar } from 'tslib';
|
|
3
|
+
|
|
2
4
|
import type terser from '@rollup/plugin-terser';
|
|
3
5
|
|
|
4
6
|
import { Env } from '@travetto/base';
|
|
5
7
|
import { ManifestModule, ManifestModuleUtil, Package, path, RootIndex } from '@travetto/manifest';
|
|
6
8
|
|
|
7
|
-
const
|
|
8
|
-
commonjs: `
|
|
9
|
-
try { globalThis.crypto = require('crypto'); } catch {}
|
|
10
|
-
try { require('./.env.js')} catch {}
|
|
9
|
+
export const RUNTIME_MODULES = 'trv_node_modules';
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
try {await import('./.env.js')} catch {}
|
|
23
|
-
`
|
|
11
|
+
const makeIntro = (doImport: (name: string) => string): string => `
|
|
12
|
+
try { (${doImport('child_process')}).execFileSync('mkdir -p node_modules/ && cp -r ${RUNTIME_MODULES}/* node_modules/', { shell:true}); } catch {}
|
|
13
|
+
try { globalThis.crypto = ${doImport('crypto')}; } catch {}
|
|
14
|
+
try { ${doImport('./.env.js')} } catch {}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
const INTRO = {
|
|
18
|
+
commonjs: `${makeIntro(v => `require('${v}')`)}
|
|
19
|
+
${__importStar.toString().replace(/function([^(]+)/, 'function __importStar')}`,
|
|
20
|
+
module: makeIntro(v => `await import('${v}')`)
|
|
24
21
|
};
|
|
25
22
|
|
|
26
23
|
function getFilesFromModule(m: ManifestModule): string[] {
|
package/support/bin/operation.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { cliTpl } from '@travetto/cli';
|
|
|
7
7
|
import { CommonPackConfig } from './types';
|
|
8
8
|
import { PackUtil } from './util';
|
|
9
9
|
import { ActiveShellCommand, ShellCommands } from './shell';
|
|
10
|
+
import { RUNTIME_MODULES } from './config';
|
|
10
11
|
|
|
11
12
|
async function writeRawFile(file: string, contents: string, mode?: string): Promise<void> {
|
|
12
13
|
await fs.writeFile(file, contents, { encoding: 'utf8', mode });
|
|
@@ -233,6 +234,22 @@ export class PackOperation {
|
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Duplicate node_modules
|
|
239
|
+
*/
|
|
240
|
+
static async * duplicateNodeModules(cfg: CommonPackConfig): AsyncIterable<string[]> {
|
|
241
|
+
const src = path.resolve(cfg.workspace, 'node_modules');
|
|
242
|
+
const dest = path.resolve(cfg.workspace, RUNTIME_MODULES);
|
|
243
|
+
|
|
244
|
+
yield* PackOperation.title(cfg, cliTpl`${{ title: 'Creating a Copy of Node Modules' }} ${{ path: path.join('node_modules') }}`);
|
|
245
|
+
|
|
246
|
+
if (cfg.ejectFile) {
|
|
247
|
+
yield ActiveShellCommand.copyRecursive(src, dest);
|
|
248
|
+
} else {
|
|
249
|
+
await PackUtil.copyRecursive(src, dest);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
236
253
|
/**
|
|
237
254
|
* Generate ZIP file for workspace
|
|
238
255
|
*/
|
package/support/pack.base.ts
CHANGED