@angular-builders/custom-esbuild 17.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.
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=custom-esbuild-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-esbuild-schema.js","sourceRoot":"","sources":["../src/custom-esbuild-schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { BuilderContext } from '@angular-devkit/architect';
2
+ import { DevServerBuilderOptions, DevServerBuilderOutput } from '@angular-devkit/build-angular';
3
+ import { json } from '@angular-devkit/core';
4
+ import { Observable } from 'rxjs';
5
+ import { CustomEsbuildDevServerSchema } from '../custom-esbuild-schema';
6
+ export declare function executeCustomDevServerBuilder(options: CustomEsbuildDevServerSchema, context: BuilderContext): Observable<DevServerBuilderOutput>;
7
+ declare const _default: import("@angular-devkit/architect/src/internal").Builder<DevServerBuilderOptions & json.JsonObject>;
8
+ export default _default;
@@ -0,0 +1,49 @@
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.executeCustomDevServerBuilder = void 0;
13
+ const path = require("node:path");
14
+ const architect_1 = require("@angular-devkit/architect");
15
+ const build_angular_1 = require("@angular-devkit/build-angular");
16
+ const core_1 = require("@angular-devkit/core");
17
+ const rxjs_1 = require("rxjs");
18
+ const utils_1 = require("../utils");
19
+ const patch_builder_context_1 = require("./patch-builder-context");
20
+ function executeCustomDevServerBuilder(options, context) {
21
+ var _a;
22
+ const buildTarget = (0, architect_1.targetFromTargetString)(
23
+ // `browserTarget` has been deprecated.
24
+ (_a = options.buildTarget) !== null && _a !== void 0 ? _a : options.browserTarget);
25
+ function getBuildTargetOptions() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return (yield context.getTargetOptions(buildTarget));
28
+ });
29
+ }
30
+ const workspaceRoot = (0, core_1.normalize)(context.workspaceRoot);
31
+ return (0, rxjs_1.from)(getBuildTargetOptions()).pipe((0, rxjs_1.switchMap)((buildOptions) => __awaiter(this, void 0, void 0, function* () {
32
+ const tsConfig = path.join((0, core_1.getSystemPath)(workspaceRoot), buildOptions.tsConfig);
33
+ const middleware = yield Promise.all((options.middlewares || []).map(path =>
34
+ // https://github.com/angular/angular-cli/pull/26212/files#diff-a99020cbdb97d20b2bc686bcb64b31942107d56db06fd880171b0a86f7859e6eR52
35
+ (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 indexHtmlTransformer = buildOptions.indexHtmlTransformer
38
+ ? yield (0, utils_1.loadModule)(workspaceRoot, buildOptions.indexHtmlTransformer, tsConfig, context.logger)
39
+ : undefined;
40
+ (0, patch_builder_context_1.patchBuilderContext)(context, buildTarget);
41
+ return {
42
+ transforms: { indexHtml: indexHtmlTransformer },
43
+ extensions: { middleware, buildPlugins },
44
+ };
45
+ })), (0, rxjs_1.switchMap)(({ transforms, extensions }) => (0, build_angular_1.executeDevServerBuilder)(options, context, transforms, extensions)));
46
+ }
47
+ exports.executeCustomDevServerBuilder = executeCustomDevServerBuilder;
48
+ exports.default = (0, architect_1.createBuilder)(executeCustomDevServerBuilder);
49
+ //# sourceMappingURL=index.js.map
@@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,EAAE,OAAO,CAAC,MAAM,CAAC,CAClE,CACF,CAAC;QAEF,MAAM,oBAAoB,GAAuB,YAAY,CAAC,oBAAoB;YAChF,CAAC,CAAC,MAAM,IAAA,kBAAU,EACd,aAAa,EACb,YAAY,CAAC,oBAAoB,EACjC,QAAQ,EACR,OAAO,CAAC,MAAM,CACf;YACH,CAAC,CAAC,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;AAtDD,sEAsDC;AAED,kBAAe,IAAA,yBAAa,EAC1B,6BAA6B,CAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { BuilderContext, Target } from '@angular-devkit/architect';
2
+ export declare function patchBuilderContext(context: BuilderContext, buildTarget: Target): void;
@@ -0,0 +1,49 @@
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.patchBuilderContext = void 0;
13
+ const executorToBuilderMap = new Map([
14
+ ['@angular-builders/custom-esbuild', '@angular-devkit/build-angular:application'],
15
+ ['@angular-builders/custom-esbuild:application', '@angular-devkit/build-angular:application'],
16
+ ]);
17
+ function cleanBuildTargetOptions(options) {
18
+ delete options.plugins;
19
+ delete options.indexHtmlTransformer;
20
+ return options;
21
+ }
22
+ function patchBuilderContext(context, buildTarget) {
23
+ const originalGetBuilderNameForTarget = context.getBuilderNameForTarget;
24
+ // We have to patch `getBuilderNameForTarget` because Angular CLI checks
25
+ // whether the runnable target is `@angular-devkit/build-angular:application`
26
+ // and then defines the server to run. If the `builderName` (returned by
27
+ // `context.getBuilderNameForTarget`) is not an `@angular-devkit/build-angular:application`,
28
+ // then it will use the Webpack server for the `dev-server target`. By patching
29
+ // the return value, Angular will use the Vite server for the `dev-server` target.
30
+ context.getBuilderNameForTarget = (target) => __awaiter(this, void 0, void 0, function* () {
31
+ const builderName = yield originalGetBuilderNameForTarget(target);
32
+ if (executorToBuilderMap.has(builderName)) {
33
+ return executorToBuilderMap.get(builderName);
34
+ }
35
+ return builderName;
36
+ });
37
+ const originalGetTargetOptions = context.getTargetOptions;
38
+ context.getTargetOptions = (target) => __awaiter(this, void 0, void 0, function* () {
39
+ const options = yield originalGetTargetOptions(target);
40
+ if (target.project === buildTarget.project &&
41
+ target.target === buildTarget.target &&
42
+ target.configuration === buildTarget.configuration) {
43
+ cleanBuildTargetOptions(options);
44
+ }
45
+ return options;
46
+ });
47
+ }
48
+ exports.patchBuilderContext = patchBuilderContext;
49
+ //# sourceMappingURL=patch-builder-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch-builder-context.js","sourceRoot":"","sources":["../../src/dev-server/patch-builder-context.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAiB;IACnD,CAAC,kCAAkC,EAAE,2CAA2C,CAAC;IACjF,CAAC,8CAA8C,EAAE,2CAA2C,CAAC;CAC9F,CAAC,CAAC;AAEH,SAAS,uBAAuB,CAAC,OAAY;IAC3C,OAAO,OAAO,CAAC,OAAO,CAAC;IACvB,OAAO,OAAO,CAAC,oBAAoB,CAAC;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAAuB,EAAE,WAAmB;IAC9E,MAAM,+BAA+B,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAExE,wEAAwE;IACxE,6EAA6E;IAC7E,wEAAwE;IACxE,4FAA4F;IAC5F,+EAA+E;IAC/E,kFAAkF;IAClF,OAAO,CAAC,uBAAuB,GAAG,CAAM,MAAM,EAAC,EAAE;QAC/C,MAAM,WAAW,GAAG,MAAM,+BAA+B,CAAC,MAAM,CAAC,CAAC;QAElE,IAAI,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC1C,OAAO,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;QAChD,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,CAAA,CAAC;IAEF,MAAM,wBAAwB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAC1D,OAAO,CAAC,gBAAgB,GAAG,CAAM,MAAM,EAAC,EAAE;QACxC,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAEvD,IACE,MAAM,CAAC,OAAO,KAAK,WAAW,CAAC,OAAO;YACtC,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM;YACpC,MAAM,CAAC,aAAa,KAAK,WAAW,CAAC,aAAa,EAClD,CAAC;YACD,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAA,CAAC;AACJ,CAAC;AAjCD,kDAiCC"}
@@ -0,0 +1,133 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "title": "Custom ESBuild dev server schema for Angular build facade",
4
+ "description": "Dev server target options",
5
+ "type": "object",
6
+ "properties": {
7
+ "browserTarget": {
8
+ "type": "string",
9
+ "description": "A browser builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
10
+ "pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$",
11
+ "x-deprecated": "Use 'buildTarget' instead."
12
+ },
13
+ "buildTarget": {
14
+ "type": "string",
15
+ "description": "A build builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
16
+ "pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
17
+ },
18
+ "port": {
19
+ "type": "number",
20
+ "description": "Port to listen on.",
21
+ "default": 4200
22
+ },
23
+ "host": {
24
+ "type": "string",
25
+ "description": "Host to listen on.",
26
+ "default": "localhost"
27
+ },
28
+ "proxyConfig": {
29
+ "type": "string",
30
+ "description": "Proxy configuration file. For more information, see https://angular.io/guide/build#proxying-to-a-backend-server."
31
+ },
32
+ "ssl": {
33
+ "type": "boolean",
34
+ "description": "Serve using HTTPS.",
35
+ "default": false
36
+ },
37
+ "sslKey": {
38
+ "type": "string",
39
+ "description": "SSL key to use for serving HTTPS."
40
+ },
41
+ "sslCert": {
42
+ "type": "string",
43
+ "description": "SSL certificate to use for serving HTTPS."
44
+ },
45
+ "headers": {
46
+ "type": "object",
47
+ "description": "Custom HTTP headers to be added to all responses.",
48
+ "propertyNames": {
49
+ "pattern": "^[-_A-Za-z0-9]+$"
50
+ },
51
+ "additionalProperties": {
52
+ "type": "string"
53
+ }
54
+ },
55
+ "open": {
56
+ "type": "boolean",
57
+ "description": "Opens the url in default browser.",
58
+ "default": false,
59
+ "alias": "o"
60
+ },
61
+ "verbose": {
62
+ "type": "boolean",
63
+ "description": "Adds more details to output logging."
64
+ },
65
+ "liveReload": {
66
+ "type": "boolean",
67
+ "description": "Whether to reload the page on change, using live-reload.",
68
+ "default": true
69
+ },
70
+ "publicHost": {
71
+ "type": "string",
72
+ "description": "The URL that the browser client (or live-reload client, if enabled) should use to connect to the development server. Use for a complex dev server setup, such as one with reverse proxies."
73
+ },
74
+ "allowedHosts": {
75
+ "type": "array",
76
+ "description": "List of hosts that are allowed to access the dev server.",
77
+ "default": [],
78
+ "items": {
79
+ "type": "string"
80
+ }
81
+ },
82
+ "servePath": {
83
+ "type": "string",
84
+ "description": "The pathname where the application will be served."
85
+ },
86
+ "disableHostCheck": {
87
+ "type": "boolean",
88
+ "description": "Don't verify connected clients are part of allowed hosts.",
89
+ "default": false
90
+ },
91
+ "hmr": {
92
+ "type": "boolean",
93
+ "description": "Enable hot module replacement.",
94
+ "default": false
95
+ },
96
+ "watch": {
97
+ "type": "boolean",
98
+ "description": "Rebuild on change.",
99
+ "default": true
100
+ },
101
+ "poll": {
102
+ "type": "number",
103
+ "description": "Enable and define the file watching poll time period in milliseconds."
104
+ },
105
+ "forceEsbuild": {
106
+ "type": "boolean",
107
+ "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.",
108
+ "default": false
109
+ },
110
+ "middlewares": {
111
+ "description": "A list of paths to Vite server middlewares",
112
+ "default": [],
113
+ "items": {
114
+ "type": "string",
115
+ "uniqueItems": true
116
+ }
117
+ }
118
+ },
119
+ "additionalProperties": false,
120
+ "anyOf": [
121
+ {
122
+ "required": [
123
+ "buildTarget"
124
+ ]
125
+ },
126
+ {
127
+ "required": [
128
+ "browserTarget"
129
+ ]
130
+ }
131
+ ],
132
+ "$id": "CustomEsbuildDevServerSchema"
133
+ }
@@ -0,0 +1,2 @@
1
+ export * from './application';
2
+ export * from './dev-server';
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./application"), exports);
18
+ __exportStar(require("./dev-server"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,+CAA6B"}
@@ -0,0 +1,5 @@
1
+ import { Path, logging } from '@angular-devkit/core';
2
+ /**
3
+ * Loads CJS and ESM modules based on extension
4
+ */
5
+ export declare function loadModule<T>(workspaceRoot: Path, relativePath: string, tsConfig: string, logger: logging.LoggerApi): Promise<T>;
package/dist/utils.js ADDED
@@ -0,0 +1,141 @@
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.loadModule = void 0;
13
+ const core_1 = require("@angular-devkit/core");
14
+ const path = require("node:path");
15
+ const url = require("node:url");
16
+ const _tsNodeRegister = (() => {
17
+ let lastTsConfig;
18
+ return (tsConfig, logger) => {
19
+ // Check if the function was previously called with the same tsconfig
20
+ if (lastTsConfig && lastTsConfig !== tsConfig) {
21
+ logger.warn(`Trying to register ts-node again with a different tsconfig - skipping the registration.
22
+ tsconfig 1: ${lastTsConfig}
23
+ tsconfig 2: ${tsConfig}`);
24
+ }
25
+ if (lastTsConfig) {
26
+ return;
27
+ }
28
+ lastTsConfig = tsConfig;
29
+ loadTsNode().register({
30
+ project: tsConfig,
31
+ compilerOptions: {
32
+ module: 'CommonJS',
33
+ types: [
34
+ 'node', // NOTE: `node` is added because users scripts can also use pure node's packages as webpack or others
35
+ ],
36
+ },
37
+ });
38
+ const tsConfigPaths = loadTsConfigPaths();
39
+ const result = tsConfigPaths.loadConfig(tsConfig);
40
+ // The `loadConfig` returns a `ConfigLoaderResult` which must be guarded with
41
+ // the `resultType` check.
42
+ if (result.resultType === 'success') {
43
+ const { absoluteBaseUrl: baseUrl, paths } = result;
44
+ if (baseUrl && paths) {
45
+ tsConfigPaths.register({ baseUrl, paths });
46
+ }
47
+ }
48
+ };
49
+ })();
50
+ /**
51
+ * check for TS node registration
52
+ * @param file: file name or file directory are allowed
53
+ * @todo tsNodeRegistration: require ts-node if file extension is TypeScript
54
+ */
55
+ function tsNodeRegister(file = '', tsConfig, logger) {
56
+ if (file === null || file === void 0 ? void 0 : file.endsWith('.ts')) {
57
+ // Register TS compiler lazily
58
+ _tsNodeRegister(tsConfig, logger);
59
+ }
60
+ }
61
+ /**
62
+ * This uses a dynamic import to load a module which may be ESM.
63
+ * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
64
+ * will currently, unconditionally downlevel dynamic import into a require call.
65
+ * require calls cannot load ESM code and will result in a runtime error. To workaround
66
+ * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
67
+ * Once TypeScript provides support for keeping the dynamic import this workaround can
68
+ * be dropped.
69
+ *
70
+ * @param modulePath The path of the module to load.
71
+ * @returns A Promise that resolves to the dynamically imported module.
72
+ */
73
+ function loadEsmModule(modulePath) {
74
+ return new Function('modulePath', `return import(modulePath);`)(modulePath);
75
+ }
76
+ /**
77
+ * Loads CJS and ESM modules based on extension
78
+ */
79
+ function loadModule(workspaceRoot, relativePath, tsConfig, logger) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const modulePath = path.join((0, core_1.getSystemPath)(workspaceRoot), relativePath);
82
+ tsNodeRegister(modulePath, tsConfig, logger);
83
+ switch (path.extname(modulePath)) {
84
+ case '.mjs':
85
+ // Load the ESM configuration file using the TypeScript dynamic import workaround.
86
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
87
+ // changed to a direct dynamic import.
88
+ return (yield loadEsmModule(url.pathToFileURL(modulePath))).default;
89
+ case '.cjs':
90
+ return require(modulePath);
91
+ case '.ts':
92
+ try {
93
+ // If it's a TS file then there are 2 cases for exporing an object.
94
+ // The first one is `export blah`, transpiled into `module.exports = { blah} `.
95
+ // The second is `export default blah`, transpiled into `{ default: { ... } }`.
96
+ return require(modulePath).default || require(modulePath);
97
+ }
98
+ catch (e) {
99
+ if (e.code === 'ERR_REQUIRE_ESM') {
100
+ // Load the ESM configuration file using the TypeScript dynamic import workaround.
101
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
102
+ // changed to a direct dynamic import.
103
+ return (yield loadEsmModule(url.pathToFileURL(modulePath))).default;
104
+ }
105
+ throw e;
106
+ }
107
+ //.js
108
+ default:
109
+ // The file could be either CommonJS or ESM.
110
+ // CommonJS is tried first then ESM if loading fails.
111
+ try {
112
+ return require(modulePath);
113
+ }
114
+ catch (e) {
115
+ if (e.code === 'ERR_REQUIRE_ESM') {
116
+ // Load the ESM configuration file using the TypeScript dynamic import workaround.
117
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
118
+ // changed to a direct dynamic import.
119
+ return (yield loadEsmModule(url.pathToFileURL(modulePath))).default;
120
+ }
121
+ throw e;
122
+ }
123
+ }
124
+ });
125
+ }
126
+ exports.loadModule = loadModule;
127
+ /**
128
+ * Loads `ts-node` lazily. Moved to a separate function to declare
129
+ * a return type, more readable than an inline variant.
130
+ */
131
+ function loadTsNode() {
132
+ return require('ts-node');
133
+ }
134
+ /**
135
+ * Loads `tsconfig-paths` lazily. Moved to a separate function to declare
136
+ * a return type, more readable than an inline variant.
137
+ */
138
+ function loadTsConfigPaths() {
139
+ return require('tsconfig-paths');
140
+ }
141
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoE;AACpE,kCAAkC;AAClC,gCAAgC;AAEhC,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE;IAC5B,IAAI,YAAgC,CAAC;IACrC,OAAO,CAAC,QAAgB,EAAE,MAAyB,EAAE,EAAE;QACrD,qEAAqE;QACrE,IAAI,YAAY,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC;iCACe,YAAY;iCACZ,QAAQ,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QAED,YAAY,GAAG,QAAQ,CAAC;QAExB,UAAU,EAAE,CAAC,QAAQ,CAAC;YACpB,OAAO,EAAE,QAAQ;YACjB,eAAe,EAAE;gBACf,MAAM,EAAE,UAAU;gBAClB,KAAK,EAAE;oBACL,MAAM,EAAE,qGAAqG;iBAC9G;aACF;SACF,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,iBAAiB,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAClD,6EAA6E;QAC7E,0BAA0B;QAC1B,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YACnD,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;gBACrB,aAAa,CAAC,QAAQ,CAA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gBAC5D,CAAC;gBAAC,OAAO,CAAM,EAAE,CAAC;oBAChB,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;wBACjC,kFAAkF;wBAClF,yFAAyF;wBACzF,sCAAsC;wBACtC,OAAO,CAAC,MAAM,aAAa,CAAiB,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;oBACtF,CAAC;oBACD,MAAM,CAAC,CAAC;gBACV,CAAC;YACH,KAAK;YACL;gBACE,4CAA4C;gBAC5C,qDAAqD;gBACrD,IAAI,CAAC;oBACH,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC7B,CAAC;gBAAC,OAAO,CAAM,EAAE,CAAC;oBAChB,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;wBACjC,kFAAkF;wBAClF,yFAAyF;wBACzF,sCAAsC;wBACtC,OAAO,CAAC,MAAM,aAAa,CAAiB,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;oBACtF,CAAC;oBAED,MAAM,CAAC,CAAC;gBACV,CAAC;QACL,CAAC;IACH,CAAC;CAAA;AAjDD,gCAiDC;AAED;;;GAGG;AACH,SAAS,UAAU;IACjB,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB;IACxB,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@angular-builders/custom-esbuild",
3
+ "version": "17.1.0-beta.0",
4
+ "description": "Custom esbuild builders for Angular build facade. Allow to modify Angular build configuration without ejecting it",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist",
8
+ "builders.json"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/just-jeb/angular-builders",
13
+ "directory": "packages/custom-esbuild"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "author": "JeB Barabanov",
19
+ "license": "MIT",
20
+ "engines": {
21
+ "node": "^14.20.0 || ^16.13.0 || >=18.10.0"
22
+ },
23
+ "keywords": [
24
+ "cli",
25
+ "angular",
26
+ "builder",
27
+ "angular6",
28
+ "angular-cli",
29
+ "esbuild",
30
+ "custom"
31
+ ],
32
+ "scripts": {
33
+ "prebuild": "yarn clean",
34
+ "build": "yarn prebuild && tsc && ts-node ../../merge-schemes.ts && yarn postbuild",
35
+ "postbuild": "yarn run e2e",
36
+ "e2e": "jest --config ../../jest-e2e.config.js",
37
+ "clean": "rimraf dist",
38
+ "ci": "./scripts/ci.sh"
39
+ },
40
+ "builders": "builders.json",
41
+ "dependencies": {
42
+ "@angular-devkit/architect": ">=0.1701.0 < 0.1800.0",
43
+ "@angular-devkit/build-angular": "^17.1.0",
44
+ "@angular-devkit/core": "^17.1.0",
45
+ "ts-node": "^10.0.0",
46
+ "tsconfig-paths": "^4.1.0"
47
+ },
48
+ "peerDependencies": {
49
+ "@angular/compiler-cli": "^17.1.0"
50
+ },
51
+ "devDependencies": {
52
+ "esbuild": "0.19.11",
53
+ "jest": "29.7.0",
54
+ "rimraf": "^5.0.0",
55
+ "typescript": "5.3.3"
56
+ },
57
+ "gitHead": "f3717627f153147ca950d2d1062ee368fbe08f2b"
58
+ }