@angular-builders/custom-esbuild 18.0.0 → 18.1.0-beta.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
|
@@ -100,19 +100,25 @@ Builder options:
|
|
|
100
100
|
"build": {
|
|
101
101
|
"builder": "@angular-builders/custom-esbuild:application",
|
|
102
102
|
"options": {
|
|
103
|
-
"plugins": ["./esbuild/plugins.ts", "./esbuild/
|
|
103
|
+
"plugins": ["./esbuild/plugins.ts", { "path": "./esbuild/define-env.ts", "options": { "stage": "development" } }],
|
|
104
104
|
"indexHtmlTransformer": "./esbuild/index-html-transformer.js",
|
|
105
105
|
"outputPath": "dist/my-cool-client",
|
|
106
106
|
"index": "src/index.html",
|
|
107
107
|
"browser": "src/main.ts",
|
|
108
108
|
"polyfills": ["zone.js"],
|
|
109
109
|
"tsConfig": "src/tsconfig.app.json"
|
|
110
|
+
},
|
|
111
|
+
"configurations": {
|
|
112
|
+
"production": {
|
|
113
|
+
"plugins": ["./esbuild/plugins.ts", { "path": "./esbuild/define-env.ts", "options": { "stage": "production" } }]
|
|
114
|
+
}
|
|
110
115
|
}
|
|
116
|
+
}
|
|
111
117
|
```
|
|
112
118
|
|
|
113
119
|
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
120
|
|
|
115
|
-
The plugin file can export either a single plugin or a list of plugins
|
|
121
|
+
The plugin file can export either a single plugin or a list of plugins. If a plugin accepts configuration then the config should be provided in `angular.json`:
|
|
116
122
|
|
|
117
123
|
```ts
|
|
118
124
|
// esbuild/plugins.ts
|
|
@@ -129,6 +135,25 @@ const defineTextPlugin: Plugin = {
|
|
|
129
135
|
export default defineTextPlugin;
|
|
130
136
|
```
|
|
131
137
|
|
|
138
|
+
OR:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
// esbuild/plugins.ts
|
|
142
|
+
import type { Plugin, PluginBuild } from 'esbuild';
|
|
143
|
+
|
|
144
|
+
function defineEnv(pluginOptions: { stage: string }): Plugin {
|
|
145
|
+
return {
|
|
146
|
+
name: 'define-env',
|
|
147
|
+
setup(build: PluginBuild) {
|
|
148
|
+
const buildOptions = build.initialOptions;
|
|
149
|
+
buildOptions.define.stage = JSON.stringify(pluginOptions.stage);
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export default defineEnv;
|
|
155
|
+
```
|
|
156
|
+
|
|
132
157
|
Or:
|
|
133
158
|
|
|
134
159
|
```ts
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"description": "Automatically clear the terminal screen during rebuilds."
|
|
153
153
|
},
|
|
154
154
|
"optimization": {
|
|
155
|
-
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.
|
|
155
|
+
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.dev/reference/configs/workspace-config#optimization-configuration.",
|
|
156
156
|
"default": true,
|
|
157
157
|
"x-user-analytics": "ep.ng_optimization",
|
|
158
158
|
"oneOf": [
|
|
@@ -297,7 +297,7 @@
|
|
|
297
297
|
"default": true
|
|
298
298
|
},
|
|
299
299
|
"sourceMap": {
|
|
300
|
-
"description": "Output source maps for scripts and styles. For more information, see https://angular.
|
|
300
|
+
"description": "Output source maps for scripts and styles. For more information, see https://angular.dev/reference/configs/workspace-config#source-map-configuration.",
|
|
301
301
|
"default": false,
|
|
302
302
|
"oneOf": [
|
|
303
303
|
{
|
|
@@ -571,7 +571,25 @@
|
|
|
571
571
|
"description": "A list of paths to ESBuild plugins",
|
|
572
572
|
"default": [],
|
|
573
573
|
"items": {
|
|
574
|
-
"
|
|
574
|
+
"anyOf": [
|
|
575
|
+
{
|
|
576
|
+
"type": "string"
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
"type": "object",
|
|
580
|
+
"properties": {
|
|
581
|
+
"path": {
|
|
582
|
+
"type": "string"
|
|
583
|
+
},
|
|
584
|
+
"options": {
|
|
585
|
+
"type": "object"
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
"required": [
|
|
589
|
+
"path"
|
|
590
|
+
]
|
|
591
|
+
}
|
|
592
|
+
],
|
|
575
593
|
"uniqueItems": true
|
|
576
594
|
}
|
|
577
595
|
},
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ApplicationBuilderOptions, DevServerBuilderOptions } from '@angular-devkit/build-angular';
|
|
2
|
+
export type PluginConfig = string | {
|
|
3
|
+
path: string;
|
|
4
|
+
options?: Record<string, unknown>;
|
|
5
|
+
};
|
|
2
6
|
export type CustomEsbuildApplicationSchema = ApplicationBuilderOptions & {
|
|
3
7
|
plugins?: string[];
|
|
4
8
|
indexHtmlTransformer?: string;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"proxyConfig": {
|
|
29
29
|
"type": "string",
|
|
30
|
-
"description": "Proxy configuration file. For more information, see https://angular.
|
|
30
|
+
"description": "Proxy configuration file. For more information, see https://angular.dev/tools/cli/serve#proxying-to-a-backend-server."
|
|
31
31
|
},
|
|
32
32
|
"ssl": {
|
|
33
33
|
"type": "boolean",
|
|
@@ -102,6 +102,19 @@
|
|
|
102
102
|
"type": "number",
|
|
103
103
|
"description": "Enable and define the file watching poll time period in milliseconds."
|
|
104
104
|
},
|
|
105
|
+
"inspect": {
|
|
106
|
+
"default": false,
|
|
107
|
+
"description": "Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are enabled.",
|
|
108
|
+
"oneOf": [
|
|
109
|
+
{
|
|
110
|
+
"type": "string",
|
|
111
|
+
"description": "Activate the inspector on host and port in the format of `[[host:]port]`. See the security warning in https://nodejs.org/docs/latest-v22.x/api/cli.html#warning-binding-inspector-to-a-public-ipport-combination-is-insecure regarding the host parameter usage."
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"type": "boolean"
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
105
118
|
"forceEsbuild": {
|
|
106
119
|
"type": "boolean",
|
|
107
120
|
"description": "Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option for the esbuild-based build system.",
|
package/dist/load-plugins.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Plugin } from 'esbuild';
|
|
2
2
|
import type { logging } from '@angular-devkit/core';
|
|
3
|
-
|
|
3
|
+
import { PluginConfig } from './custom-esbuild-schema';
|
|
4
|
+
export declare function loadPlugins(pluginConfig: PluginConfig[] | undefined, workspaceRoot: string, tsConfig: string, logger: logging.LoggerApi): Promise<Plugin[]>;
|
package/dist/load-plugins.js
CHANGED
|
@@ -12,9 +12,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.loadPlugins = void 0;
|
|
13
13
|
const path = require("node:path");
|
|
14
14
|
const common_1 = require("@angular-builders/common");
|
|
15
|
-
function loadPlugins(
|
|
15
|
+
function loadPlugins(pluginConfig, workspaceRoot, tsConfig, logger) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const plugins = yield Promise.all((
|
|
17
|
+
const plugins = yield Promise.all((pluginConfig || []).map((pluginConfig) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if (typeof pluginConfig === 'string') {
|
|
19
|
+
return (0, common_1.loadModule)(path.join(workspaceRoot, pluginConfig), tsConfig, logger);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const pluginFactory = yield (0, common_1.loadModule)(path.join(workspaceRoot, pluginConfig.path), tsConfig, logger);
|
|
23
|
+
return pluginFactory(pluginConfig.options);
|
|
24
|
+
}
|
|
25
|
+
})));
|
|
18
26
|
return plugins.flat();
|
|
19
27
|
});
|
|
20
28
|
}
|
package/dist/load-plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-plugins.js","sourceRoot":"","sources":["../src/load-plugins.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kCAAkC;AAGlC,qDAAsD;
|
|
1
|
+
{"version":3,"file":"load-plugins.js","sourceRoot":"","sources":["../src/load-plugins.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kCAAkC;AAGlC,qDAAsD;AAGtD,SAAsB,WAAW,CAC/B,YAAwC,EACxC,aAAqB,EACrB,QAAgB,EAChB,MAAyB;;QAEzB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAM,YAAY,EAAC,EAAE;YAC1C,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;gBACrC,OAAO,IAAA,mBAAU,EAAoB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;YACjG,CAAC;iBAAM,CAAC;gBACN,MAAM,aAAa,GAAG,MAAM,IAAA,mBAAU,EAA6B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;gBAClI,OAAO,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC7C,CAAC;QAEH,CAAC,CAAA,CACF,CACF,CAAC;QAEF,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;CAAA;AApBD,kCAoBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-builders/custom-esbuild",
|
|
3
|
-
"version": "18.0.0",
|
|
3
|
+
"version": "18.1.0-beta.0",
|
|
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": [
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"prebuild": "yarn clean",
|
|
34
34
|
"build": "yarn prebuild && tsc && ts-node ../../merge-schemes.ts && yarn postbuild",
|
|
35
|
-
"postbuild": "yarn run e2e",
|
|
35
|
+
"postbuild": "yarn test && yarn run e2e",
|
|
36
|
+
"test": "jest --config ../../jest-ut.config.js",
|
|
36
37
|
"e2e": "jest --config ../../jest-e2e.config.js",
|
|
37
38
|
"clean": "rimraf dist",
|
|
38
39
|
"ci": "./scripts/ci.sh"
|
|
@@ -49,11 +50,11 @@
|
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@angular/build": "^18.0.0",
|
|
52
|
-
"esbuild": "0.
|
|
53
|
+
"esbuild": "0.21.5",
|
|
53
54
|
"jest": "29.7.0",
|
|
54
55
|
"rimraf": "^5.0.0",
|
|
55
56
|
"ts-node": "^10.0.0",
|
|
56
57
|
"typescript": "5.4.5"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "1b0decdede47b0d8a5a7049bbe68d8859c204edf"
|
|
59
60
|
}
|