@angular-builders/custom-esbuild 17.1.0-beta.0 → 17.1.0-beta.2

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
@@ -100,7 +100,7 @@ Builder options:
100
100
  "build": {
101
101
  "builder": "@angular-builders/custom-esbuild:application",
102
102
  "options": {
103
- "plugins": ["./esbuild/plugin-1.js", "./esbuild/plugin-2.js"],
103
+ "plugins": ["./esbuild/plugins.ts", "./esbuild/plugin-2.js"],
104
104
  "indexHtmlTransformer": "./esbuild/index-html-transformer.js",
105
105
  "outputPath": "dist/my-cool-client",
106
106
  "index": "src/index.html",
@@ -112,6 +112,49 @@ Builder options:
112
112
 
113
113
  In the above example, we specify the list of `plugins` that should implement the ESBuild plugin schema. These plugins are custom user plugins and are added to the original ESBuild Angular configuration. Additionally, the `indexHtmlTransformer` property is used to specify the path to the file that exports the function used to modify the `index.html`.
114
114
 
115
+ The plugin file can export either a single plugin or a list of plugins:
116
+
117
+ ```ts
118
+ // esbuild/plugins.ts
119
+ import type { Plugin, PluginBuild } from 'esbuild';
120
+
121
+ const defineTextPlugin: Plugin = {
122
+ name: 'define-text',
123
+ setup(build: PluginBuild) {
124
+ const options = build.initialOptions;
125
+ options.define.buildText = JSON.stringify('This text is provided during the compilation');
126
+ },
127
+ };
128
+
129
+ export default defineTextPlugin;
130
+ ```
131
+
132
+ Or:
133
+
134
+ ```ts
135
+ // esbuild/plugins.ts
136
+ import type { Plugin, PluginBuild } from 'esbuild';
137
+
138
+ const defineTextPlugin: Plugin = {
139
+ name: 'define-text',
140
+ setup(build: PluginBuild) {
141
+ const options = build.initialOptions;
142
+ options.define.buildText = JSON.stringify('This text is provided during the compilation');
143
+ },
144
+ };
145
+
146
+ const updateExternalPlugin: Plugin = {
147
+ name: 'update-external',
148
+ setup(build: PluginBuild) {
149
+ const options = build.initialOptions;
150
+ options.external ??= [];
151
+ options.external.push('elysia');
152
+ },
153
+ };
154
+
155
+ export default [defineTextPlugin, updateExternalPlugin];
156
+ ```
157
+
115
158
  ## Custom ESBuild `dev-server`
116
159
 
117
160
  The `@angular-builders/custom-esbuild:dev-server` is an enhanced version of the `@angular-devkit/build-angular:dev-server` builder that allows the specification of `middlewares` (Vite's `Connect` functions). It also obtains `plugins` and `indexHtmlTransformer` from the `:application` configuration to run the Vite server with all the necessary configuration applied.
@@ -10,17 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.buildCustomEsbuildApplication = void 0;
13
+ const path = require("node:path");
13
14
  const architect_1 = require("@angular-devkit/architect");
14
15
  const build_angular_1 = require("@angular-devkit/build-angular");
15
16
  const core_1 = require("@angular-devkit/core");
16
17
  const rxjs_1 = require("rxjs");
17
18
  const utils_1 = require("../utils");
19
+ const load_plugins_1 = require("../load-plugins");
18
20
  function buildCustomEsbuildApplication(options, context) {
19
21
  const workspaceRoot = (0, core_1.normalize)(context.workspaceRoot);
20
- const tsConfig = `${(0, core_1.getSystemPath)(workspaceRoot)}/${options.tsConfig}`;
22
+ const tsConfig = path.join((0, core_1.getSystemPath)(workspaceRoot), options.tsConfig);
21
23
  return (0, rxjs_1.defer)(() => __awaiter(this, void 0, void 0, function* () {
22
- const paths = options.plugins || [];
23
- const codePlugins = yield Promise.all(paths.map(path => (0, utils_1.loadModule)(workspaceRoot, path, tsConfig, context.logger)));
24
+ const codePlugins = yield (0, load_plugins_1.loadPlugins)(options.plugins, workspaceRoot, tsConfig, context.logger);
24
25
  const indexHtmlTransformer = options.indexHtmlTransformer
25
26
  ? yield (0, utils_1.loadModule)(workspaceRoot, options.indexHtmlTransformer, tsConfig, context.logger)
26
27
  : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA0E;AAC1E,iEAAiE;AACjE,+CAAsE;AAEtE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G9C,SAAgB,6BAA6B,CAC3C,OAAuC,EACvC,OAAuB;IAEvB,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,oBAAa,EAAC,aAAa,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3E,OAAO,IAAA,YAAK,EAAC,GAAS,EAAE;QACtB,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAW,EAAC,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAEhG,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB;YACvD,CAAC,CAAC,MAAM,IAAA,kBAAU,EAAC,aAAa,EAAE,OAAO,CAAC,oBAAoB,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC;YACzF,CAAC,CAAC,SAAS,CAAC;QAEd,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAkC,CAAC;IAC/E,CAAC,CAAA,CAAC,CAAC,IAAI,CAAC,IAAA,gBAAS,EAAC,UAAU,CAAC,EAAE,CAAC,IAAA,gCAAgB,EAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC;AAhBD,sEAgBC;AAED,kBAAe,IAAA,yBAAa,EAC1B,6BAA6B,CAC9B,CAAC"}
@@ -16,6 +16,7 @@ const build_angular_1 = require("@angular-devkit/build-angular");
16
16
  const core_1 = require("@angular-devkit/core");
17
17
  const rxjs_1 = require("rxjs");
18
18
  const utils_1 = require("../utils");
19
+ const load_plugins_1 = require("../load-plugins");
19
20
  const patch_builder_context_1 = require("./patch-builder-context");
20
21
  function executeCustomDevServerBuilder(options, context) {
21
22
  var _a;
@@ -33,7 +34,7 @@ function executeCustomDevServerBuilder(options, context) {
33
34
  const middleware = yield Promise.all((options.middlewares || []).map(path =>
34
35
  // https://github.com/angular/angular-cli/pull/26212/files#diff-a99020cbdb97d20b2bc686bcb64b31942107d56db06fd880171b0a86f7859e6eR52
35
36
  (0, utils_1.loadModule)(workspaceRoot, path, tsConfig, context.logger)));
36
- const buildPlugins = yield Promise.all((buildOptions.plugins || []).map(path => (0, utils_1.loadModule)(workspaceRoot, path, tsConfig, context.logger)));
37
+ const buildPlugins = yield (0, load_plugins_1.loadPlugins)(buildOptions.plugins, workspaceRoot, tsConfig, context.logger);
37
38
  const indexHtmlTransformer = buildOptions.indexHtmlTransformer
38
39
  ? yield (0, utils_1.loadModule)(workspaceRoot, buildOptions.indexHtmlTransformer, tsConfig, context.logger)
39
40
  : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dev-server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kCAAkC;AAClC,yDAAkG;AAClG,iEAIuC;AAEvC,+CAAsE;AACtE,+BAAmD;AAInD,oCAAsC;AACtC,mEAA8D;AAM9D,SAAgB,6BAA6B,CAC3C,OAAqC,EACrC,OAAuB;;IAEvB,MAAM,WAAW,GAAG,IAAA,kCAAsB;IACxC,uCAAuC;IACvC,MAAA,OAAO,CAAC,WAAW,mCAAI,OAAO,CAAC,aAAc,CAC9C,CAAC;IAEF,SAAe,qBAAqB;;YAClC,OAAO,CAAC,MAAM,OAAO,CAAC,gBAAgB,CACpC,WAAW,CACZ,CAA8C,CAAC;QAClD,CAAC;KAAA;IAED,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEvD,OAAO,IAAA,WAAI,EAAC,qBAAqB,EAAE,CAAC,CAAC,IAAI,CACvC,IAAA,gBAAS,EAAC,CAAM,YAAY,EAAC,EAAE;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,oBAAa,EAAC,aAAa,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;QAEhF,MAAM,UA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AAC,SAAS,CAAC;QAEd,IAAA,2CAAmB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAE1C,OAAO;YACL,UAAU,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAE;YAC/C,UAAU,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE;SACzC,CAAC;IACJ,CAAC,CAAA,CAAC,EACF,IAAA,gBAAS,EAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,CACvC,IAAA,uCAAuB,EAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAClE,CACF,CAAC;AACJ,CAAC;AAvDD,sEAuDC;AAED,kBAAe,IAAA,yBAAa,EAC1B,6BAA6B,CAC9B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'esbuild';
2
+ import type { Path, logging } from '@angular-devkit/core';
3
+ export declare function loadPlugins(paths: string[] | undefined, workspaceRoot: Path, tsConfig: string, logger: logging.LoggerApi): Promise<Plugin[]>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.loadPlugins = void 0;
13
+ const utils_1 = require("./utils");
14
+ function loadPlugins(paths, workspaceRoot, tsConfig, logger) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const plugins = yield Promise.all((paths || []).map(path => (0, utils_1.loadModule)(workspaceRoot, path, tsConfig, logger)));
17
+ return plugins.flat();
18
+ });
19
+ }
20
+ exports.loadPlugins = loadPlugins;
21
+ //# sourceMappingURL=load-plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-plugins.js","sourceRoot":"","sources":["../src/load-plugins.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,mCAAqC;AAErC,SAAsB,WAAW,CAC/B,KAA2B,EAC3B,aAAmB,EACnB,QAAgB,EAChB,MAAyB;;QAEzB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,kBAAU,EAAoB,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAChG,CAAC;QAEF,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;CAAA;AAXD,kCAWC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-builders/custom-esbuild",
3
- "version": "17.1.0-beta.0",
3
+ "version": "17.1.0-beta.2",
4
4
  "description": "Custom esbuild builders for Angular build facade. Allow to modify Angular build configuration without ejecting it",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -49,10 +49,10 @@
49
49
  "@angular/compiler-cli": "^17.1.0"
50
50
  },
51
51
  "devDependencies": {
52
- "esbuild": "0.19.11",
52
+ "esbuild": "0.20.0",
53
53
  "jest": "29.7.0",
54
54
  "rimraf": "^5.0.0",
55
55
  "typescript": "5.3.3"
56
56
  },
57
- "gitHead": "f3717627f153147ca950d2d1062ee368fbe08f2b"
57
+ "gitHead": "6399221460cdc49510b2226d31f98c89ce42a468"
58
58
  }