@adobe/helix-deploy 12.3.11 → 12.4.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [12.4.1](https://github.com/adobe/helix-deploy/compare/v12.4.0...v12.4.1) (2024-12-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([#762](https://github.com/adobe/helix-deploy/issues/762)) ([ebba7c8](https://github.com/adobe/helix-deploy/commit/ebba7c86fdbd0e57935f50f9db85de81e4d12539))
7
+
8
+ # [12.4.0](https://github.com/adobe/helix-deploy/compare/v12.3.11...v12.4.0) (2024-12-06)
9
+
10
+
11
+ ### Features
12
+
13
+ * support `esbuild` as alternative bundler ([#760](https://github.com/adobe/helix-deploy/issues/760)) ([fc9c85a](https://github.com/adobe/helix-deploy/commit/fc9c85a7671d736fc219fb0c24b93590f68ce873))
14
+
1
15
  ## [12.3.11](https://github.com/adobe/helix-deploy/compare/v12.3.10...v12.3.11) (2024-12-05)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-deploy",
3
- "version": "12.3.11",
3
+ "version": "12.4.1",
4
4
  "description": "Library and Commandline Tools to build and deploy OpenWhisk Actions",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/adobe/helix-deploy#readme",
@@ -41,7 +41,7 @@
41
41
  "@adobe/helix-shared-process-queue": "3.0.4",
42
42
  "@aws-sdk/client-apigatewayv2": "3.699.0",
43
43
  "@aws-sdk/client-lambda": "3.699.0",
44
- "@aws-sdk/client-s3": "3.703.0",
44
+ "@aws-sdk/client-s3": "3.705.0",
45
45
  "@aws-sdk/client-secrets-manager": "3.699.0",
46
46
  "@aws-sdk/client-ssm": "3.699.0",
47
47
  "@aws-sdk/client-sts": "3.699.0",
@@ -50,13 +50,14 @@
50
50
  "@google-cloud/storage": "7.14.0",
51
51
  "archiver": "7.0.1",
52
52
  "chalk-template": "1.1.0",
53
- "dotenv": "16.4.6",
53
+ "dotenv": "16.4.7",
54
+ "esbuild": "0.24.0",
54
55
  "escalade": "3.2.0",
55
56
  "fs-extra": "11.2.0",
56
57
  "isomorphic-git": "1.27.2",
57
58
  "openwhisk": "3.21.8",
58
59
  "semver": "7.6.3",
59
- "webpack": "5.97.0",
60
+ "webpack": "5.97.1",
60
61
  "yargs": "17.7.2"
61
62
  },
62
63
  "devDependencies": {
package/src/BaseConfig.js CHANGED
@@ -212,7 +212,8 @@ export default class BaseConfig {
212
212
  .withCleanupMinor(argv.cleanupMinor)
213
213
  .withCleanupMajor(argv.cleanupMajor)
214
214
  .withPackageToken(argv.packageToken)
215
- .withProperties(argv.property);
215
+ .withProperties(argv.property)
216
+ .withBundler(argv.bundler);
216
217
  }
217
218
 
218
219
  withVerbose(enable) {
@@ -565,6 +566,14 @@ export default class BaseConfig {
565
566
  return this;
566
567
  }
567
568
 
569
+ withBundler(bundler) {
570
+ if (!bundler) {
571
+ return this;
572
+ }
573
+ this.bundler = bundler;
574
+ return this;
575
+ }
576
+
568
577
  get log() {
569
578
  if (!this._logger) {
570
579
  // poor men's logging...
@@ -0,0 +1,186 @@
1
+ /*
2
+ * Copyright 2019 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import { fileURLToPath } from 'url';
13
+ import path from 'path';
14
+ import fse from 'fs-extra';
15
+ import * as esbuild from 'esbuild';
16
+ import chalk from 'chalk-template';
17
+
18
+ import processQueue from '@adobe/helix-shared-process-queue';
19
+
20
+ import BaseBundler from './BaseBundler.js';
21
+
22
+ // eslint-disable-next-line no-underscore-dangle
23
+ const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
24
+
25
+ /**
26
+ * Webpack based bundler
27
+ */
28
+ export default class ESBuildBundler extends BaseBundler {
29
+ /**
30
+ * Create a new bundler.
31
+ *
32
+ * @param {import('../BaseConfig.js')} cfg base config
33
+ */
34
+ constructor(cfg) {
35
+ super(cfg);
36
+ this.arch = 'node';
37
+ this.type = 'esbuild';
38
+ }
39
+
40
+ async init() {
41
+ if (!this.cfg.esm) {
42
+ throw new Error('ESBuild bundler only supports ESM builds.');
43
+ }
44
+ }
45
+
46
+ async getESBuildConfig() {
47
+ const { cfg } = this;
48
+ /** @type {esbuild.BuildOptions} */
49
+ const opts = {
50
+ format: 'esm',
51
+ platform: 'node',
52
+ bundle: true,
53
+ outfile: path.relative(cfg.cwd, cfg.bundle),
54
+ external: [
55
+ '@aws-sdk/*',
56
+ // the following are imported by the universal adapter and are assumed to be available
57
+ './params.json',
58
+ 'aws-sdk',
59
+ '@google-cloud/secret-manager',
60
+ '@google-cloud/storage',
61
+ ],
62
+ banner: {
63
+ js: [
64
+ 'import { createRequire } from "module";',
65
+ 'const require = createRequire(import.meta.url);',
66
+ '',
67
+ ].join('\n'),
68
+ },
69
+ entryPoints: [
70
+ cfg.adapterFile || path.resolve(__dirname, '..', 'template', 'node-index.mjs'),
71
+ ],
72
+ absWorkingDir: cfg.cwd,
73
+ plugins: [{
74
+ name: 'alias-main',
75
+ setup: (build) => {
76
+ build.onResolve({ filter: /^\.\/main\.js$/ }, () => ({ path: cfg.file }));
77
+ // use @adobe/helix-universal in the calling service, not ours
78
+ build.onResolve(
79
+ { filter: /^@adobe\/helix-universal$/ },
80
+ (args) => ({ path: path.resolve(cfg.cwd, 'node_modules', args.path, 'src', 'index.js') }),
81
+ );
82
+ cfg.externals.forEach((filter) => {
83
+ build.onResolve({ filter }, (args) => ({ path: args.path, external: true }));
84
+ });
85
+ cfg.serverlessExternals.forEach((filter) => {
86
+ build.onResolve({ filter }, (args) => ({ path: args.path, external: true }));
87
+ });
88
+ },
89
+ }],
90
+ metafile: true,
91
+ };
92
+ if (cfg.minify) {
93
+ opts.minify = cfg.minify;
94
+ }
95
+
96
+ if (cfg.progressHandler) {
97
+ this.initProgressHandler(opts, cfg);
98
+ }
99
+ return opts;
100
+ }
101
+
102
+ async createESBuildBundle(arch) {
103
+ const { cfg } = this;
104
+ if (!cfg.depFile) {
105
+ throw Error('dependencies info path is undefined');
106
+ }
107
+ const m = cfg.minify ? 'minified ' : '';
108
+ if (!cfg.progressHandler) {
109
+ cfg.log.info(`--: creating ${arch} ${m}bundle using esbuild ...`);
110
+ }
111
+ const config = await this.getESBuildConfig();
112
+ const result = await esbuild.build(config);
113
+
114
+ await this.resolveDependencyInfos(result.metafile);
115
+ // write dependencies info file
116
+ await fse.writeJson(cfg.depFile, cfg.dependencies, { spaces: 2 });
117
+ if (!cfg.progressHandler) {
118
+ cfg.log.info(chalk`{green ok:} created ${arch} bundle {yellow ${config.outfile}}`);
119
+ }
120
+ return result;
121
+ }
122
+
123
+ async createBundle() {
124
+ if (!this.cfg.bundle) {
125
+ throw Error('bundle path is undefined');
126
+ }
127
+ return this.createESBuildBundle('node');
128
+ }
129
+
130
+ /**
131
+ * Resolves the dependencies by chunk. eg:
132
+ *
133
+ * {
134
+ * 'src/idx_json.bundle.js': [{
135
+ * id: '@adobe/helix-epsagon:1.2.0',
136
+ * name: '@adobe/helix-epsagon',
137
+ * version: '1.2.0' },
138
+ * ],
139
+ * ...
140
+ * }
141
+ */
142
+ async resolveDependencyInfos(metafile) {
143
+ const { cfg } = this;
144
+
145
+ // get list of dependencies
146
+ const resolved = {};
147
+ const deps = {};
148
+
149
+ const depNames = [...Object.keys(metafile.inputs)];
150
+ await processQueue(depNames, async (depName) => {
151
+ const absDepPath = path.resolve(cfg.cwd, depName);
152
+ const segs = absDepPath.split('/');
153
+ let idx = segs.lastIndexOf('node_modules');
154
+ if (idx < 0) {
155
+ return;
156
+ }
157
+ if (idx >= 0) {
158
+ idx += 1;
159
+ if (segs[idx].charAt(0) === '@') {
160
+ idx += 1;
161
+ }
162
+ }
163
+ segs.splice(idx + 1);
164
+ const dir = path.resolve('/', ...segs);
165
+ try {
166
+ if (!resolved[dir]) {
167
+ const pkgJson = await fse.readJson(path.resolve(dir, 'package.json'));
168
+ const id = `${pkgJson.name}:${pkgJson.version}`;
169
+ resolved[dir] = {
170
+ id,
171
+ name: pkgJson.name,
172
+ version: pkgJson.version,
173
+ };
174
+ }
175
+ const dep = resolved[dir];
176
+ deps[dep.id] = dep;
177
+ } catch (e) {
178
+ // ignore
179
+ }
180
+ });
181
+
182
+ // sort the deps
183
+ cfg.dependencies.main = Object.values(deps)
184
+ .sort((d0, d1) => d0.name.localeCompare(d1.name));
185
+ }
186
+ }
package/src/cli.js CHANGED
@@ -22,12 +22,14 @@ import AWSDeployer from './deploy/AWSDeployer.js';
22
22
  import GoogleDeployer from './deploy/GoogleDeployer.js';
23
23
  import ActionBuilder from './ActionBuilder.js';
24
24
  import WebpackBundler from './bundler/WebpackBundler.js';
25
+ import ESBuildBundler from './bundler/ESBuildBundler.js';
25
26
 
26
27
  const PLUGINS = [
27
28
  OpenWhiskDeployer,
28
29
  AWSDeployer,
29
30
  GoogleDeployer,
30
31
  WebpackBundler,
32
+ ESBuildBundler,
31
33
  ];
32
34
 
33
35
  const PKG_CONF = [