@travetto/pack 5.0.0-rc.9 → 5.0.0

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
@@ -43,6 +43,7 @@ Options:
43
43
  --env-file <string> Env Flag File Name (default: ".env")
44
44
  --manifest-file <string> Manifest File Name (default: "manifest.json")
45
45
  -wr, --include-workspace-resources Include workspace resources (default: false)
46
+ -np, --npm-package <string> External NPM Packages (default: [])
46
47
  -m, --module <module> Module to run for
47
48
  -h, --help display help for command
48
49
  ```
@@ -108,6 +109,7 @@ Options:
108
109
  --env-file <string> Env Flag File Name (default: ".env")
109
110
  --manifest-file <string> Manifest File Name (default: "manifest.json")
110
111
  -wr, --include-workspace-resources Include workspace resources (default: false)
112
+ -np, --npm-package <string> External NPM Packages (default: [])
111
113
  -m, --module <module> Module to run for
112
114
  -h, --help display help for command
113
115
  ```
@@ -136,6 +138,7 @@ Options:
136
138
  --env-file <string> Env Flag File Name (default: ".env")
137
139
  --manifest-file <string> Manifest File Name (default: "manifest.json")
138
140
  -wr, --include-workspace-resources Include workspace resources (default: false)
141
+ -np, --npm-package <string> External NPM Packages (default: [])
139
142
  -df, --docker-factory <string> Docker Factory source (default: "@travetto/pack/support/pack.dockerfile")
140
143
  -di, --docker-image <string> Docker Image to extend (default: "node:22-alpine")
141
144
  -dn, --docker-name <string> Docker Image Name (default: "travetto_pack")
@@ -259,6 +262,7 @@ echo "RUN addgroup -g 2000 app && adduser -D -G app -u 2000 app" >> $DIST/Docker
259
262
  echo "RUN mkdir /app && chown app:app /app" >> $DIST/Dockerfile
260
263
  echo "COPY --chown=\"app:app\" . /app" >> $DIST/Dockerfile
261
264
  echo "ENV NODE_OPTIONS=\"\"" >> $DIST/Dockerfile
265
+ echo "" >> $DIST/Dockerfile
262
266
  echo "USER app" >> $DIST/Dockerfile
263
267
  echo "WORKDIR /app" >> $DIST/Dockerfile
264
268
  echo "ENTRYPOINT [\"/app/todo-app.sh\"]" >> $DIST/Dockerfile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/pack",
3
- "version": "5.0.0-rc.9",
3
+ "version": "5.0.0",
4
4
  "description": "Code packing utilities",
5
5
  "keywords": [
6
6
  "travetto",
@@ -29,12 +29,12 @@
29
29
  "@rollup/plugin-json": "^6.1.0",
30
30
  "@rollup/plugin-node-resolve": "^15.2.3",
31
31
  "@rollup/plugin-terser": "^0.4.4",
32
- "@travetto/runtime": "^5.0.0-rc.9",
33
- "@travetto/terminal": "^5.0.0-rc.9",
34
- "rollup": "^4.18.0"
32
+ "@travetto/runtime": "^5.0.0",
33
+ "@travetto/terminal": "^5.0.0",
34
+ "rollup": "^4.20.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@travetto/cli": "^5.0.0-rc.9"
37
+ "@travetto/cli": "^5.0.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/cli": {
@@ -29,6 +29,23 @@ export class PackConfigUtil {
29
29
  }
30
30
  }
31
31
 
32
+ /**
33
+ * Install docker pages in either apk or apt environments
34
+ */
35
+ static dockerNodePackageInstall(cfg: DockerPackConfig): string {
36
+ const out: string[] = [];
37
+ for (const item of cfg.externalDependencies ?? []) {
38
+ out.push(item.endsWith(':from-source') ?
39
+ `RUN npm_config_build_from_source=true npm install ${item.split(':')[0]} --build-from-source` :
40
+ `RUN npm install ${item}`
41
+ );
42
+ }
43
+ if (out.length) {
44
+ out.unshift(`WORKDIR ${cfg.dockerRuntime.folder}`);
45
+ }
46
+ return out.join('\n');
47
+ }
48
+
32
49
  /**
33
50
  * Setup docker ports
34
51
  */
@@ -113,6 +130,7 @@ export class PackConfigUtil {
113
130
  return [
114
131
  this.dockerInit(cfg),
115
132
  this.dockerWorkspace(cfg),
133
+ this.dockerNodePackageInstall(cfg),
116
134
  this.dockerEntrypoint(cfg)
117
135
  ].join('\n');
118
136
  }
package/src/types.ts CHANGED
@@ -19,6 +19,7 @@ export type CommonPackConfig = {
19
19
  rollupConfiguration: string;
20
20
  entryPoint: string;
21
21
  entryArguments: string[];
22
+ externalDependencies: string[];
22
23
  minify: boolean;
23
24
  sourcemap: boolean;
24
25
  includeSources: boolean;
@@ -72,5 +73,6 @@ export type CoreRollupConfig = {
72
73
  entry: string;
73
74
  files: string[];
74
75
  ignore: Set<string>;
76
+ external: string[];
75
77
  minify: Parameters<typeof terser>[0];
76
78
  };
@@ -67,7 +67,8 @@ export class PackOperation {
67
67
  ['BUNDLE_SOURCES', cfg.includeSources],
68
68
  ['BUNDLE_OUTPUT', cfg.buildDir],
69
69
  ['BUNDLE_FORMAT', Runtime.workspace.type],
70
- ['BUNDLE_ENV_FILE', cfg.envFile]
70
+ ['BUNDLE_ENV_FILE', cfg.envFile],
71
+ ['BUNDLE_EXTERNAL', cfg.externalDependencies.join(',')]
71
72
  ] as const)
72
73
  .filter(x => x[1] === false || x[1])
73
74
  .map(x => [x[0], `${x[1]}`])
@@ -71,6 +71,9 @@ export abstract class BasePackCommand implements CliCommandShape {
71
71
  @CliFlag({ desc: 'Include workspace resources', short: 'wr' })
72
72
  includeWorkspaceResources: boolean = false;
73
73
 
74
+ @CliFlag({ desc: 'External NPM Packages', short: 'np', name: 'npm-package', envVars: ['PACK_EXTERNAL_PACKAGES'] })
75
+ externalDependencies: string[] = [];
76
+
74
77
  @Ignore()
75
78
  module: string;
76
79
 
@@ -16,6 +16,7 @@ export default function buildConfig(): RollupOptions {
16
16
  return {
17
17
  input: [config.entry],
18
18
  output: config.output,
19
+ external: config.external,
19
20
  plugins: [
20
21
  jsonImport(),
21
22
  travettoEntryPlugin(config),
@@ -86,9 +86,10 @@ export function getCoreConfig(): CoreRollupConfig {
86
86
  const ignoreFiles = ignoreModules.flatMap(getFilesFromModule);
87
87
  const minify = getMinifyConfig();
88
88
  const envFile = new EnvProp('BUNDLE_ENV_FILE').val;
89
+ const external = new EnvProp('BUNDLE_EXTERNAL').list ?? [];
89
90
 
90
91
  return {
91
- output, entry, files, envFile, minify,
92
+ output, entry, files, envFile, minify, external,
92
93
  ignore: new Set([...ignoreModules.map(x => x.name), ...ignoreFiles]),
93
94
  };
94
95
  }