@travetto/pack 3.1.0-rc.3 → 3.1.0-rc.5
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/README.md +5 -9
- package/package.json +3 -3
- package/support/bin/config.ts +13 -16
- package/support/bin/operation.ts +3 -21
- package/support/pack.base.ts +1 -1
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ mkdir -p $DIST
|
|
|
167
167
|
|
|
168
168
|
echo "Writing .env.js"
|
|
169
169
|
|
|
170
|
-
echo "process.env.TRV_MANIFEST = '
|
|
170
|
+
echo "process.env.TRV_MANIFEST = 'manifest.json';" > $DIST/.env.js
|
|
171
171
|
echo "process.env.TRV_MODULE = '$MOD';" >> $DIST/.env.js
|
|
172
172
|
echo "process.env.TRV_CLI_IPC = '';" >> $DIST/.env.js
|
|
173
173
|
|
|
@@ -175,7 +175,7 @@ echo "process.env.TRV_CLI_IPC = '';" >> $DIST/.env.js
|
|
|
175
175
|
|
|
176
176
|
echo "Writing package.json"
|
|
177
177
|
|
|
178
|
-
echo "{\"type\":\"commonjs\"}" > $DIST/package.json
|
|
178
|
+
echo "{\"type\":\"commonjs\",\"main\":\"todo-app.js\"}" > $DIST/package.json
|
|
179
179
|
|
|
180
180
|
# Writing entry scripts todo-app.sh args=(run:rest)
|
|
181
181
|
|
|
@@ -199,17 +199,13 @@ chmod 755 $DIST/todo-app.cmd
|
|
|
199
199
|
|
|
200
200
|
echo "Copying over resources"
|
|
201
201
|
|
|
202
|
-
mkdir -p $DIST/node_modules/$MOD
|
|
203
|
-
cp $TRV_OUT/node_modules/$MOD/package.json $DIST/node_modules/$MOD/package.json
|
|
204
|
-
mkdir -p $DIST/node_modules/@travetto/manifest
|
|
205
|
-
cp $TRV_OUT/node_modules/@travetto/manifest/package.json $DIST/node_modules/@travetto/manifest/package.json
|
|
206
202
|
cp -r -p $ROOT/resources $DIST/resources
|
|
207
203
|
|
|
208
|
-
# Writing Manifest
|
|
204
|
+
# Writing Manifest manifest.json
|
|
209
205
|
|
|
210
|
-
echo "Writing Manifest
|
|
206
|
+
echo "Writing Manifest manifest.json"
|
|
211
207
|
|
|
212
|
-
TRV_MODULE=$MOD npx trv manifest $DIST/
|
|
208
|
+
TRV_MODULE=$MOD npx trv manifest $DIST/manifest.json prod
|
|
213
209
|
|
|
214
210
|
# Bundling Output minify=true sourcemap=false entryPoint=@travetto/cli/support/entry.cli
|
|
215
211
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
|
-
"version": "3.1.0-rc.
|
|
3
|
+
"version": "3.1.0-rc.5",
|
|
4
4
|
"description": "Code packing utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"travetto",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"@rollup/plugin-json": "^6.0.0",
|
|
29
29
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
30
30
|
"@rollup/plugin-terser": "^0.4.0",
|
|
31
|
-
"@travetto/base": "^3.1.0-rc.
|
|
31
|
+
"@travetto/base": "^3.1.0-rc.1",
|
|
32
32
|
"rollup": "^3.17.2",
|
|
33
33
|
"rollup-plugin-sourcemaps": "^0.6.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^3.1.0-rc.
|
|
36
|
+
"@travetto/cli": "^3.1.0-rc.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
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
|
-
|
|
9
|
-
try {
|
|
10
|
-
|
|
9
|
+
const makeIntro = (doImport: (name: string) => string, ...extra: string[]): string => [
|
|
10
|
+
`try { globalThis.crypto = ${doImport('crypto')}; } catch {}`,
|
|
11
|
+
`try { ${doImport('./.env.js')} } catch {}`,
|
|
12
|
+
...extra
|
|
13
|
+
].map(x => x.trim()).join('\n');
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
`,
|
|
20
|
-
module: `
|
|
21
|
-
tyr{ globalThis.crypto = await import('crypto'); } catch {}
|
|
22
|
-
try {await import('./.env.js')} catch {}
|
|
23
|
-
`
|
|
15
|
+
const INTRO = {
|
|
16
|
+
commonjs: makeIntro(
|
|
17
|
+
v => `require('${v}')`,
|
|
18
|
+
__importStar.toString().replace(/function([^(]+)/, 'function __importStar'),
|
|
19
|
+
),
|
|
20
|
+
module: makeIntro(v => `await import('${v}')`)
|
|
24
21
|
};
|
|
25
22
|
|
|
26
23
|
function getFilesFromModule(m: ManifestModule): string[] {
|
package/support/bin/operation.ts
CHANGED
|
@@ -120,7 +120,7 @@ export class PackOperation {
|
|
|
120
120
|
static async * writeEnv(cfg: CommonPackConfig): AsyncIterable<string[]> {
|
|
121
121
|
const file = '.env.js';
|
|
122
122
|
const env = {
|
|
123
|
-
TRV_MANIFEST:
|
|
123
|
+
TRV_MANIFEST: 'manifest.json',
|
|
124
124
|
TRV_MODULE: cfg.module,
|
|
125
125
|
TRV_CLI_IPC: ''
|
|
126
126
|
};
|
|
@@ -184,31 +184,13 @@ export class PackOperation {
|
|
|
184
184
|
dest: path.resolve(cfg.workspace, 'resources')
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
-
const copyFiles = [
|
|
188
|
-
RootIndex.manifest.modules[RootIndex.mainModule.name],
|
|
189
|
-
RootIndex.manifest.modules['@travetto/manifest']
|
|
190
|
-
].map(mod => ({
|
|
191
|
-
src: path.resolve(RootIndex.outputRoot, mod.outputFolder, 'package.json'),
|
|
192
|
-
dest: path.resolve(cfg.workspace, mod.outputFolder, 'package.json'),
|
|
193
|
-
destFolder: path.resolve(cfg.workspace, mod.outputFolder)
|
|
194
|
-
}));
|
|
195
|
-
|
|
196
187
|
yield* PackOperation.title(cfg, cliTpl`${{ title: 'Copying over resources' }}`);
|
|
197
188
|
|
|
198
189
|
if (cfg.ejectFile) {
|
|
199
|
-
yield* copyFiles.flatMap(mod => [
|
|
200
|
-
ActiveShellCommand.mkdir(path.dirname(mod.dest)),
|
|
201
|
-
ActiveShellCommand.copy(mod.src, mod.dest)
|
|
202
|
-
]);
|
|
203
190
|
if (resources.count) {
|
|
204
191
|
yield ActiveShellCommand.copyRecursive(resources.src, path.resolve(cfg.workspace, 'resources'));
|
|
205
192
|
}
|
|
206
193
|
} else {
|
|
207
|
-
for (const { src, dest, destFolder } of copyFiles) {
|
|
208
|
-
await fs.mkdir(destFolder, { recursive: true });
|
|
209
|
-
await fs.copyFile(src, dest);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
194
|
if (resources.count) {
|
|
213
195
|
await fs.mkdir(path.dirname(resources.dest), { recursive: true });
|
|
214
196
|
await PackUtil.copyRecursive(resources.src, resources.dest);
|
|
@@ -220,11 +202,11 @@ export class PackOperation {
|
|
|
220
202
|
* Produce the output manifest, only including prod dependencies
|
|
221
203
|
*/
|
|
222
204
|
static async * writeManifest(cfg: CommonPackConfig): AsyncIterable<string[]> {
|
|
223
|
-
const out = path.resolve(cfg.workspace, '
|
|
205
|
+
const out = path.resolve(cfg.workspace, 'manifest.json');
|
|
224
206
|
const cmd = ['npx', 'trv', 'manifest', out, 'prod'];
|
|
225
207
|
const env = { TRV_MODULE: cfg.module };
|
|
226
208
|
|
|
227
|
-
yield* PackOperation.title(cfg, cliTpl`${{ title: 'Writing Manifest' }} ${{ path:
|
|
209
|
+
yield* PackOperation.title(cfg, cliTpl`${{ title: 'Writing Manifest' }} ${{ path: 'manifest.json' }}`);
|
|
228
210
|
|
|
229
211
|
if (cfg.ejectFile) {
|
|
230
212
|
yield [...Object.entries(env).map(([k, v]) => `${k}=${v}`), ...cmd];
|
package/support/pack.base.ts
CHANGED
|
@@ -101,7 +101,7 @@ export abstract class BasePackCommand implements CliCommandShape {
|
|
|
101
101
|
|
|
102
102
|
async main(args: string[] = []): Promise<void> {
|
|
103
103
|
this.entryArguments = [...args, ...this.#unknownArgs ?? []];
|
|
104
|
-
this.module ||= RootIndex.
|
|
104
|
+
this.module ||= RootIndex.mainModuleName;
|
|
105
105
|
this.mainName ??= path.basename(this.module);
|
|
106
106
|
|
|
107
107
|
const stream = this.runOperations();
|