@davnx/webpack 1.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.
@@ -0,0 +1,186 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createProdWebpackConfig = createProdWebpackConfig;
37
+ const app_plugin_1 = require("@nx/webpack/app-plugin");
38
+ const fs = __importStar(require("node:fs"));
39
+ const path = __importStar(require("node:path"));
40
+ const glob_1 = require("glob");
41
+ const nodeExternals = __importStar(require("webpack-node-externals"));
42
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
43
+ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
44
+ function buildScopePatterns(orgScopes) {
45
+ const allowlistPatterns = orgScopes.map((scope) => new RegExp(`${scope.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/`));
46
+ const scopePrefixes = orgScopes.map((scope) => (scope.endsWith('/') ? scope : `${scope}/`));
47
+ return { allowlistPatterns, scopePrefixes };
48
+ }
49
+ function createProdWebpackConfig(options) {
50
+ const { appRoot, outputDir, main, tsConfig, workspaceRoot, assets = [], additionalEntryPoints = [], runtimeDependencies = [], memoryLimit = 8192, generatePackageJson = true, buildLibsFromSource = false, ormConfigPath, migrationsDir = './src/migrations', orgScopes = [], bundlePackages = [], nodeExternalsConfig: userNodeExternalsConfig, webpackConfigPath, } = options;
51
+ const { allowlistPatterns, scopePrefixes } = buildScopePatterns(orgScopes);
52
+ // Build combined allowlist: orgScopes + bundlePackages + user-provided
53
+ const bundlePatterns = bundlePackages.map((pkg) => new RegExp(`^${pkg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(/|$)`));
54
+ const combinedAllowlist = [
55
+ ...allowlistPatterns,
56
+ ...bundlePatterns,
57
+ ...(userNodeExternalsConfig?.allowlist || []),
58
+ ];
59
+ // Detect ormconfig.ts for the app so we can build it for TypeORM CLI in production
60
+ let resolvedOrmConfigPath;
61
+ if (ormConfigPath !== undefined) {
62
+ resolvedOrmConfigPath = ormConfigPath ? path.join(appRoot, ormConfigPath) : null;
63
+ }
64
+ else {
65
+ const candidate = path.join(appRoot, './src/ormconfig.ts');
66
+ resolvedOrmConfigPath = fs.existsSync(candidate) ? candidate : null;
67
+ }
68
+ const hasOrmconfig = resolvedOrmConfigPath && fs.existsSync(resolvedOrmConfigPath);
69
+ const webpackConfigs = [];
70
+ const externalsConfig = [
71
+ nodeExternals({
72
+ allowlist: combinedAllowlist,
73
+ additionalModuleDirs: userNodeExternalsConfig?.additionalModuleDirs || [],
74
+ ...(userNodeExternalsConfig?.importType && { importType: userNodeExternalsConfig.importType }),
75
+ }),
76
+ ({ request }, callback) => {
77
+ if (request &&
78
+ (request.startsWith(path.join(workspaceRoot, 'apps')) ||
79
+ request.startsWith(path.join(workspaceRoot, 'libs')))) {
80
+ return callback();
81
+ }
82
+ if (request && scopePrefixes.some((prefix) => request.startsWith(prefix))) {
83
+ return callback();
84
+ }
85
+ if (request && !(request.startsWith('./') || request.startsWith('..'))) {
86
+ return callback(null, `commonjs ${request}`);
87
+ }
88
+ return callback();
89
+ },
90
+ ];
91
+ const productionBuildConfig = {
92
+ externals: externalsConfig,
93
+ output: {
94
+ path: outputDir,
95
+ clean: false,
96
+ },
97
+ devtool: 'inline-source-map',
98
+ mode: 'production',
99
+ plugins: [
100
+ new app_plugin_1.NxAppWebpackPlugin({
101
+ target: 'node22',
102
+ compiler: 'tsc',
103
+ main,
104
+ additionalEntryPoints,
105
+ externalDependencies: [],
106
+ mergeExternals: true,
107
+ memoryLimit,
108
+ tsConfig,
109
+ assets,
110
+ namedChunks: true,
111
+ optimization: true,
112
+ outputHashing: 'none',
113
+ generatePackageJson,
114
+ runtimeDependencies,
115
+ buildLibsFromSource,
116
+ typeCheckOptions: {
117
+ async: false,
118
+ },
119
+ sourceMap: 'inline-source-map',
120
+ progress: false,
121
+ })
122
+ ],
123
+ };
124
+ webpackConfigs.push(productionBuildConfig);
125
+ if (hasOrmconfig && resolvedOrmConfigPath) {
126
+ const migrationsEntryPoints = [];
127
+ const migrationsGlobPath = path.join(appRoot, migrationsDir, '*.ts');
128
+ const migrationFiles = (0, glob_1.globSync)(migrationsGlobPath);
129
+ migrationFiles.forEach((filename) => {
130
+ const migrationName = path.basename(filename, '.ts');
131
+ migrationsEntryPoints.push({
132
+ entryName: `migrations/${migrationName}`,
133
+ entryPath: filename,
134
+ });
135
+ });
136
+ const ormconfigRelative = './' + path.relative(appRoot, resolvedOrmConfigPath);
137
+ const ormconfigBuildConfig = {
138
+ ...productionBuildConfig,
139
+ output: {
140
+ ...productionBuildConfig.output,
141
+ filename: (pathData) => {
142
+ if (pathData.runtime === 'main') {
143
+ return 'ormconfig.js';
144
+ }
145
+ return '[name].js';
146
+ },
147
+ library: {
148
+ type: 'commonjs',
149
+ },
150
+ clean: false,
151
+ },
152
+ devtool: false,
153
+ plugins: [
154
+ new app_plugin_1.NxAppWebpackPlugin({
155
+ target: 'node22',
156
+ compiler: 'tsc',
157
+ main: ormconfigRelative,
158
+ externalDependencies: [],
159
+ additionalEntryPoints: migrationsEntryPoints,
160
+ mergeExternals: true,
161
+ tsConfig,
162
+ assets: [],
163
+ namedChunks: true,
164
+ memoryLimit,
165
+ optimization: false,
166
+ outputHashing: 'none',
167
+ generatePackageJson: false,
168
+ buildLibsFromSource,
169
+ skipTypeChecking: true,
170
+ sourceMap: false,
171
+ progress: !process.env.CI,
172
+ }),
173
+ ],
174
+ };
175
+ webpackConfigs.push(ormconfigBuildConfig);
176
+ }
177
+ // Apply user webpack overrides if configured
178
+ if (webpackConfigPath) {
179
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
180
+ const overrideModule = require(path.resolve(appRoot, webpackConfigPath));
181
+ const overrideFn = overrideModule.default || overrideModule;
182
+ return webpackConfigs.map((config) => overrideFn(config));
183
+ }
184
+ return webpackConfigs;
185
+ }
186
+ //# sourceMappingURL=create-webpack-prod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-webpack-prod.js","sourceRoot":"","sources":["../../../libs/webpack/src/create-webpack-prod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,0DAyKC;AAtND,uDAA4D;AAC5D,4CAA8B;AAC9B,gDAAkC;AAClC,+BAAgC;AAChC,sEAAwD;AAExD,iEAAiE;AACjE,MAAM,0BAA0B,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAgC7E,SAAS,kBAAkB,CAAC,SAAmB;IAC7C,MAAM,iBAAiB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,MAAM,C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cAAc,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC5C,CAAC;IAED,6CAA6C;IAC7C,IAAI,iBAAiB,EAAE,CAAC;QACtB,iEAAiE;QACjE,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC;QACzE,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,IAAI,cAAc,CAAC;QAC5D,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,42 @@
1
+ export interface BuildExecutorOptions {
2
+ entryFile: string;
3
+ tsConfigFile: string;
4
+ outputPath?: string;
5
+ assets?: string[];
6
+ additionalEntryPoints?: Array<{
7
+ entryName: string;
8
+ entryPath: string;
9
+ }>;
10
+ runtimeDependencies?: string[];
11
+ ormConfigPath?: string;
12
+ migrationsDir?: string;
13
+ memoryLimit?: number;
14
+ generatePackageJson?: boolean;
15
+ buildLibsFromSource?: boolean;
16
+ orgScopes?: string[];
17
+ bundlePackages?: string[];
18
+ nodeExternalsConfig?: {
19
+ allowlist?: string[];
20
+ additionalModuleDirs?: string[];
21
+ importType?: string;
22
+ };
23
+ webpackConfigPath?: string;
24
+ }
25
+ interface ExecutorContext {
26
+ root: string;
27
+ projectName?: string;
28
+ projectsConfigurations?: {
29
+ projects: Record<string, {
30
+ root: string;
31
+ }>;
32
+ };
33
+ }
34
+ /**
35
+ * Production webpack build executor for NestJS applications.
36
+ */
37
+ declare function buildExecutor(options: BuildExecutorOptions, context: ExecutorContext): AsyncGenerator<{
38
+ success: boolean;
39
+ outfile?: string;
40
+ }>;
41
+ export default buildExecutor;
42
+ //# sourceMappingURL=build.impl.d.ts.map
@@ -0,0 +1,107 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const path = __importStar(require("node:path"));
37
+ const create_webpack_prod_1 = require("../../create-webpack-prod");
38
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
39
+ const webpack = require('webpack');
40
+ /**
41
+ * Production webpack build executor for NestJS applications.
42
+ */
43
+ async function* buildExecutor(options, context) {
44
+ process.env.NODE_ENV = 'production';
45
+ const projectConfig = context.projectsConfigurations.projects[context.projectName];
46
+ const workspaceRoot = context.root;
47
+ const projectRoot = path.join(workspaceRoot, projectConfig.root);
48
+ const outputPath = options.outputPath
49
+ ? path.join(workspaceRoot, options.outputPath)
50
+ : path.join(workspaceRoot, 'dist', projectConfig.root);
51
+ // Resolve entry/tsconfig relative to project root (absolute paths avoid
52
+ // NxAppWebpackPlugin's normalizeRelativePaths collision with executor options)
53
+ const entryFile = options.entryFile || './src/deployments/service/main.ts';
54
+ const tsConfigFile = options.tsConfigFile || './tsconfig.app.json';
55
+ const resolvedMain = path.resolve(projectRoot, entryFile);
56
+ const resolvedTsConfig = path.resolve(projectRoot, tsConfigFile);
57
+ const configs = (0, create_webpack_prod_1.createProdWebpackConfig)({
58
+ appName: context.projectName,
59
+ appRoot: projectRoot,
60
+ outputDir: outputPath,
61
+ main: resolvedMain,
62
+ tsConfig: resolvedTsConfig,
63
+ assets: options.assets || [],
64
+ additionalEntryPoints: options.additionalEntryPoints || [],
65
+ runtimeDependencies: options.runtimeDependencies || [],
66
+ memoryLimit: options.memoryLimit || 8192,
67
+ generatePackageJson: options.generatePackageJson !== false,
68
+ buildLibsFromSource: options.buildLibsFromSource || false,
69
+ ormConfigPath: options.ormConfigPath,
70
+ migrationsDir: options.migrationsDir || './src/migrations',
71
+ workspaceRoot,
72
+ orgScopes: options.orgScopes || [],
73
+ bundlePackages: options.bundlePackages || [],
74
+ nodeExternalsConfig: options.nodeExternalsConfig,
75
+ webpackConfigPath: options.webpackConfigPath,
76
+ });
77
+ const configArray = Array.isArray(configs) ? configs : [configs];
78
+ for (const config of configArray) {
79
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
80
+ const { watch: _watch, ...normalizedConfig } = config;
81
+ const compiler = webpack(normalizedConfig);
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ const stats = await new Promise((resolve, reject) => {
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ compiler.run((err, stats) => {
86
+ if (err)
87
+ return reject(err);
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ compiler.close((closeErr) => {
90
+ if (closeErr)
91
+ console.error('[build] webpack close error:', closeErr);
92
+ });
93
+ resolve(stats);
94
+ });
95
+ });
96
+ console.info(stats.toString(config.stats || { colors: true, chunks: false }));
97
+ if (stats.hasErrors()) {
98
+ yield { success: false };
99
+ return;
100
+ }
101
+ }
102
+ yield { success: true, outfile: path.join(outputPath, 'main.js') };
103
+ }
104
+ exports.default = buildExecutor;
105
+ module.exports = buildExecutor;
106
+ module.exports.default = buildExecutor;
107
+ //# sourceMappingURL=build.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.impl.js","sourceRoot":"","sources":["../../../../../libs/webpack/src/executors/build/build.impl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mEAAoE;AAEpE,iEAAiE;AACjE,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAgCnC;;GAEG;AACH,KAAK,SAAS,CAAC,CAAC,aAAa,CAC3B,OAA6B,EAC7B,OAAwB;IAExB,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IAEpC,MAAM,aAAa,GAAG,OAAO,CAAC,sBAAuB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC;IACrF,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IACnC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU;QACnC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC;QAC9C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAEzD,wEAAwE;IACxE,+EAA+E;IAC/E,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,mCAAmC,CAAC;IAC3E,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,qBAAqB,CAAC;IACnE,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO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AC,CAAC;QAE3C,8DAA8D;QAC9D,MAAM,KAAK,GAAQ,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACvD,8DAA8D;YAC9D,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAiB,EAAE,KAAU,EAAE,EAAE;gBAC7C,IAAI,GAAG;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,8DAA8D;gBAC9D,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAa,EAAE,EAAE;oBAC/B,IAAI,QAAQ;wBAAE,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAC;gBACxE,CAAC,CAAC,CAAC;gBACH,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAE9E,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;YACtB,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YACzB,OAAO;QACT,CAAC;IACH,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,kBAAe,aAAa,CAAC;AAC7B,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC;AAC/B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC"}
@@ -0,0 +1,115 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "title": "NestJS Webpack Build",
5
+ "description": "Build a NestJS application using webpack.",
6
+ "cli": "nx",
7
+ "type": "object",
8
+ "properties": {
9
+ "entryFile": {
10
+ "type": "string",
11
+ "description": "Path to the main entry-point file, relative to project root.",
12
+ "x-completion-type": "file",
13
+ "x-priority": "important",
14
+ "default": "./src/deployments/service/main.ts"
15
+ },
16
+ "tsConfigFile": {
17
+ "type": "string",
18
+ "description": "Path to the TypeScript configuration file, relative to project root.",
19
+ "x-completion-type": "file",
20
+ "x-priority": "important",
21
+ "default": "./tsconfig.app.json"
22
+ },
23
+ "outputPath": {
24
+ "type": "string",
25
+ "description": "Output directory path, relative to workspace root.",
26
+ "x-completion-type": "directory"
27
+ },
28
+ "assets": {
29
+ "type": "array",
30
+ "description": "List of static assets to copy.",
31
+ "items": { "type": "string" },
32
+ "default": []
33
+ },
34
+ "additionalEntryPoints": {
35
+ "type": "array",
36
+ "description": "Additional webpack entry points.",
37
+ "items": {
38
+ "type": "object",
39
+ "properties": {
40
+ "entryName": { "type": "string" },
41
+ "entryPath": { "type": "string" }
42
+ }
43
+ },
44
+ "default": []
45
+ },
46
+ "runtimeDependencies": {
47
+ "type": "array",
48
+ "description": "Runtime dependencies to include in generated package.json.",
49
+ "items": { "type": "string" },
50
+ "default": []
51
+ },
52
+ "ormConfigPath": {
53
+ "type": "string",
54
+ "description": "Path to ormconfig.ts relative to project root. Auto-detected from src/ormconfig.ts if not specified."
55
+ },
56
+ "migrationsDir": {
57
+ "type": "string",
58
+ "description": "Path to migrations directory relative to project root.",
59
+ "default": "./src/migrations"
60
+ },
61
+ "memoryLimit": {
62
+ "type": "number",
63
+ "description": "Memory limit in MB for TypeScript type checker.",
64
+ "default": 8192
65
+ },
66
+ "generatePackageJson": {
67
+ "type": "boolean",
68
+ "description": "Generate package.json in output.",
69
+ "default": true
70
+ },
71
+ "buildLibsFromSource": {
72
+ "type": "boolean",
73
+ "description": "Read buildable libraries from source.",
74
+ "default": false
75
+ },
76
+ "orgScopes": {
77
+ "type": "array",
78
+ "description": "Organization scopes to bundle rather than externalize (e.g. ['@myorg']). Matching packages are bundled into the webpack output.",
79
+ "items": { "type": "string" },
80
+ "default": []
81
+ },
82
+ "bundlePackages": {
83
+ "type": "array",
84
+ "description": "Explicit package names to force-bundle into the output instead of externalizing (e.g. ['lodash', 'my-pkg']).",
85
+ "items": { "type": "string" },
86
+ "default": []
87
+ },
88
+ "nodeExternalsConfig": {
89
+ "type": "object",
90
+ "description": "Override options for webpack-node-externals. Merged with defaults — allowlist entries are appended to orgScopes and bundlePackages.",
91
+ "properties": {
92
+ "allowlist": {
93
+ "type": "array",
94
+ "description": "Additional patterns to allowlist (bundle instead of externalize).",
95
+ "items": { "type": "string" }
96
+ },
97
+ "additionalModuleDirs": {
98
+ "type": "array",
99
+ "description": "Additional directories to scan for modules to externalize.",
100
+ "items": { "type": "string" }
101
+ },
102
+ "importType": {
103
+ "type": "string",
104
+ "description": "Module import type for externalized packages (default: 'commonjs')."
105
+ }
106
+ }
107
+ },
108
+ "webpackConfigPath": {
109
+ "type": "string",
110
+ "description": "Path to a JS/TS file (relative to project root) that exports a (config) => config function for custom webpack overrides.",
111
+ "x-completion-type": "file"
112
+ }
113
+ },
114
+ "required": ["entryFile", "tsConfigFile"]
115
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "continuous": true,
5
+ "title": "NestJS Webpack Serve",
6
+ "description": "Serve a NestJS application with webpack watch mode and integrated devserver.",
7
+ "cli": "nx",
8
+ "type": "object",
9
+ "properties": {
10
+ "entryFile": {
11
+ "type": "string",
12
+ "description": "Path to the main entry-point file, relative to project root.",
13
+ "x-completion-type": "file",
14
+ "x-priority": "important",
15
+ "default": "./src/deployments/service/main.ts"
16
+ },
17
+ "tsConfigFile": {
18
+ "type": "string",
19
+ "description": "Path to the TypeScript configuration file, relative to project root.",
20
+ "x-completion-type": "file",
21
+ "x-priority": "important",
22
+ "default": "./tsconfig.app.json"
23
+ },
24
+ "outputPath": {
25
+ "type": "string",
26
+ "description": "Output directory path, relative to workspace root.",
27
+ "x-completion-type": "directory"
28
+ },
29
+ "assets": {
30
+ "type": "array",
31
+ "description": "List of static assets to copy.",
32
+ "items": { "type": "string" },
33
+ "default": []
34
+ },
35
+ "configEnv": {
36
+ "type": "string",
37
+ "description": "Environment name for config YAML resolution (config.{env}.yaml).",
38
+ "default": "development"
39
+ },
40
+ "memoryLimit": {
41
+ "type": "number",
42
+ "description": "Memory limit in MB for TypeScript type checker.",
43
+ "default": 8192
44
+ },
45
+ "childCount": {
46
+ "type": "number",
47
+ "description": "Number of child processes for the devserver.",
48
+ "default": 1
49
+ },
50
+ "buildLibsFromSource": {
51
+ "type": "boolean",
52
+ "description": "Read buildable libraries from source.",
53
+ "default": true
54
+ },
55
+ "orgScopes": {
56
+ "type": "array",
57
+ "description": "Organization scopes to bundle rather than externalize (e.g. ['@myorg']). Matching packages are bundled into the webpack output.",
58
+ "items": { "type": "string" },
59
+ "default": []
60
+ },
61
+ "bundlePackages": {
62
+ "type": "array",
63
+ "description": "Explicit package names to force-bundle into the output instead of externalizing (e.g. ['lodash', 'my-pkg']).",
64
+ "items": { "type": "string" },
65
+ "default": []
66
+ },
67
+ "nodeExternalsConfig": {
68
+ "type": "object",
69
+ "description": "Override options for webpack-node-externals. Merged with defaults — allowlist entries are appended to orgScopes and bundlePackages.",
70
+ "properties": {
71
+ "allowlist": {
72
+ "type": "array",
73
+ "description": "Additional patterns to allowlist (bundle instead of externalize).",
74
+ "items": { "type": "string" }
75
+ },
76
+ "additionalModuleDirs": {
77
+ "type": "array",
78
+ "description": "Additional directories to scan for modules to externalize.",
79
+ "items": { "type": "string" }
80
+ },
81
+ "importType": {
82
+ "type": "string",
83
+ "description": "Module import type for externalized packages (default: 'commonjs')."
84
+ }
85
+ }
86
+ },
87
+ "webpackConfigPath": {
88
+ "type": "string",
89
+ "description": "Path to a JS/TS file (relative to project root) that exports a (config) => config function for custom webpack overrides.",
90
+ "x-completion-type": "file"
91
+ }
92
+ },
93
+ "required": ["entryFile", "tsConfigFile"]
94
+ }
@@ -0,0 +1,42 @@
1
+ export interface ServeExecutorOptions {
2
+ entryFile: string;
3
+ tsConfigFile: string;
4
+ outputPath?: string;
5
+ assets?: string[];
6
+ configEnv?: string;
7
+ memoryLimit?: number;
8
+ childCount?: number;
9
+ buildLibsFromSource?: boolean;
10
+ orgScopes?: string[];
11
+ bundlePackages?: string[];
12
+ nodeExternalsConfig?: {
13
+ allowlist?: string[];
14
+ additionalModuleDirs?: string[];
15
+ importType?: string;
16
+ };
17
+ webpackConfigPath?: string;
18
+ }
19
+ interface ExecutorContext {
20
+ root: string;
21
+ projectName?: string;
22
+ projectsConfigurations?: {
23
+ projects: Record<string, {
24
+ root: string;
25
+ }>;
26
+ };
27
+ }
28
+ /**
29
+ * Dev serve executor — webpack watch mode with integrated devserver.
30
+ *
31
+ * Owns the full devserver lifecycle:
32
+ * 1. Starts webpack in watch mode
33
+ * 2. On first successful build, forks main.devserver.js with proper env vars
34
+ * 3. On subsequent builds, POSTs /webpack/reload to devserver
35
+ * 4. On shutdown, cleans up devserver and webpack watcher
36
+ */
37
+ declare function serveExecutor(options: ServeExecutorOptions, context: ExecutorContext): AsyncGenerator<{
38
+ success: boolean;
39
+ baseUrl?: string;
40
+ }>;
41
+ export default serveExecutor;
42
+ //# sourceMappingURL=serve.impl.d.ts.map