@travetto/pack 7.0.0-rc.3 → 7.0.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 CHANGED
@@ -196,7 +196,7 @@ echo "TRV_RESOURCE_OVERRIDES=@#resources=@@#resources" >> $DIST/.env
196
196
 
197
197
  echo "Writing package.json"
198
198
 
199
- echo "{\"type\":\"commonjs\",\"main\":\"todo-app.js\"}" > $DIST/package.json
199
+ echo "{\"type\":\"module\",\"main\":\"todo-app.js\"}" > $DIST/package.json
200
200
 
201
201
  # Writing entry scripts todo-app.sh args=(web:http)
202
202
 
@@ -237,7 +237,6 @@ export BUNDLE_COMPRESS=true
237
237
  export BUNDLE_SOURCEMAP=false
238
238
  export BUNDLE_SOURCES=false
239
239
  export BUNDLE_OUTPUT=$DIST
240
- export BUNDLE_FORMAT=commonjs
241
240
  export BUNDLE_ENV_FILE=.env
242
241
  export TRV_MANIFEST=$TRV_OUT/node_modules/$MOD
243
242
  cd $TRV_OUT
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@travetto/pack",
3
- "version": "7.0.0-rc.3",
3
+ "version": "7.0.0-rc.5",
4
+ "type": "module",
4
5
  "description": "Code packing utilities",
5
6
  "keywords": [
6
7
  "travetto",
@@ -29,12 +30,12 @@
29
30
  "@rollup/plugin-json": "^6.1.0",
30
31
  "@rollup/plugin-node-resolve": "^16.0.3",
31
32
  "@rollup/plugin-terser": "^0.4.4",
32
- "@travetto/runtime": "^7.0.0-rc.3",
33
- "@travetto/terminal": "^7.0.0-rc.3",
34
- "rollup": "^4.53.3"
33
+ "@travetto/runtime": "^7.0.0-rc.5",
34
+ "@travetto/terminal": "^7.0.0-rc.5",
35
+ "rollup": "^4.54.0"
35
36
  },
36
37
  "peerDependencies": {
37
- "@travetto/cli": "^7.0.0-rc.3"
38
+ "@travetto/cli": "^7.0.0-rc.5"
38
39
  },
39
40
  "peerDependenciesMeta": {
40
41
  "@travetto/cli": {
@@ -66,7 +66,6 @@ export class PackOperation {
66
66
  ['BUNDLE_SOURCEMAP', config.sourcemap],
67
67
  ['BUNDLE_SOURCES', config.includeSources],
68
68
  ['BUNDLE_OUTPUT', config.buildDirectory],
69
- ['BUNDLE_FORMAT', Runtime.workspace.type],
70
69
  ['BUNDLE_ENV_FILE', config.envFile],
71
70
  ['BUNDLE_EXTERNAL', config.externalDependencies.map(mod => mod.split(':')[0]).join(',')]
72
71
  ] as const)
@@ -101,7 +100,7 @@ export class PackOperation {
101
100
  */
102
101
  static async * writePackageJson(config: CommonPackConfig): AsyncIterable<string[]> {
103
102
  const file = 'package.json';
104
- const pkg = { type: Runtime.workspace.type, main: config.mainFile };
103
+ const pkg = { type: 'module', main: config.mainFile };
105
104
 
106
105
  yield* PackOperation.title(config, cliTpl`${{ title: 'Writing' }} ${{ path: file }}`);
107
106
 
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import type { OutputOptions } from 'rollup';
4
4
  import type terser from '@rollup/plugin-terser';
5
5
 
6
- import { type ManifestModule, ManifestModuleUtil, type NodeModuleType } from '@travetto/manifest';
6
+ import { type ManifestModule, ManifestModuleUtil } from '@travetto/manifest';
7
7
  import { EnvProp, Runtime, RuntimeIndex } from '@travetto/runtime';
8
8
 
9
9
  import { CoreRollupConfig } from '../../src/types.ts';
@@ -21,21 +21,11 @@ function getFilesFromModule(mod: ManifestModule): string[] {
21
21
  .map(([file]) => ManifestModuleUtil.withOutputExtension(path.resolve(mod.outputFolder, file)));
22
22
  }
23
23
 
24
- function getFormat(value: string = 'commonjs'): NodeModuleType {
25
- switch (value) {
26
- case 'module':
27
- case 'commonjs': return value;
28
- default: return 'commonjs';
29
- }
30
- }
31
-
32
24
  export function getOutput(): OutputOptions {
33
- const format = getFormat(process.env.BUNDLE_FORMAT);
34
25
  const output = process.env.BUNDLE_OUTPUT!;
35
26
  const mainFile = process.env.BUNDLE_MAIN_FILE!;
36
27
  return {
37
- format,
38
- interop: format === 'commonjs' ? 'auto' : undefined,
28
+ format: 'module',
39
29
  sourcemapPathTransform: (source, map): string =>
40
30
  Runtime.stripWorkspacePath(path.resolve(path.dirname(map), source)),
41
31
  sourcemap: new EnvProp('BUNDLE_SOURCEMAP').bool ?? false,
@@ -12,12 +12,11 @@ export function travettoEntryPlugin(config: CoreRollupConfig): Plugin {
12
12
  .map(file => file.split('node_modules/').pop()!)
13
13
  .flatMap(file => file.endsWith('/__index__.js') ? [file.replace('/__index__.js', ''), file] : [file]);
14
14
 
15
- const operation = config.output.format === 'module' ? 'import' : 'require';
16
15
  const importer = `
17
16
  function trvImp(path) {
18
17
  switch (path) {
19
- ${imports.map(file => ` case '${file}': return ${operation}('${file}')`).join('\n')}
20
- default: return ${operation}(path); // Fall back for built-ins
18
+ ${imports.map(file => ` case '${file}': return import('${file}')`).join('\n')}
19
+ default: return import(path); // Fall back for built-ins
21
20
  }
22
21
  }
23
22
  globalThis.${GLOBAL_IMPORT} = trvImp;