@genesislcap/webpack-builder 14.26.8-alpha-64bb9e2.0 → 14.27.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/dist/commands/build.d.ts +3 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +22 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +10 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/config/devServer.d.ts +4 -0
- package/dist/config/devServer.d.ts.map +1 -0
- package/dist/config/devServer.js +75 -0
- package/dist/config/entry.d.ts +4 -0
- package/dist/config/entry.d.ts.map +1 -0
- package/dist/config/entry.js +19 -0
- package/dist/config/federation.d.ts +15 -0
- package/dist/config/federation.d.ts.map +1 -0
- package/dist/config/federation.js +69 -0
- package/dist/config/getConfig.d.ts +9 -0
- package/dist/config/getConfig.d.ts.map +1 -0
- package/dist/config/getConfig.js +46 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/config/module.d.ts +4 -0
- package/dist/config/module.d.ts.map +1 -0
- package/dist/config/module.js +20 -0
- package/dist/config/optimization.d.ts +4 -0
- package/dist/config/optimization.d.ts.map +1 -0
- package/dist/config/optimization.js +39 -0
- package/dist/config/output.d.ts +4 -0
- package/dist/config/output.d.ts.map +1 -0
- package/dist/config/output.js +34 -0
- package/dist/config/plugins.d.ts +4 -0
- package/dist/config/plugins.d.ts.map +1 -0
- package/dist/config/plugins.js +79 -0
- package/dist/config/resolveLoader.d.ts +4 -0
- package/dist/config/resolveLoader.d.ts.map +1 -0
- package/dist/config/resolveLoader.js +18 -0
- package/dist/{rules → config/rules}/fileRules.d.ts +5 -5
- package/dist/config/rules/fileRules.d.ts.map +1 -0
- package/dist/{rules → config/rules}/fileRules.js +4 -4
- package/dist/{rules → config/rules}/scriptRules.d.ts +3 -4
- package/dist/config/rules/scriptRules.d.ts.map +1 -0
- package/dist/{rules → config/rules}/scriptRules.js +4 -6
- package/dist/{rules → config/rules}/styleRules.d.ts +10 -23
- package/dist/config/rules/styleRules.d.ts.map +1 -0
- package/dist/config/rules/styleRules.js +38 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/utils/fs.d.ts +2 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +18 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/package.json +5 -4
- package/src/commands/build.ts +24 -0
- package/src/commands/dev.ts +7 -0
- package/src/commands/index.ts +2 -0
- package/src/config/devServer.ts +88 -0
- package/src/config/entry.ts +24 -0
- package/src/config/federation.ts +91 -0
- package/src/config/getConfig.ts +49 -0
- package/src/config/index.ts +1 -0
- package/src/config/module.ts +21 -0
- package/src/config/optimization.ts +45 -0
- package/src/config/output.ts +42 -0
- package/src/config/plugins.ts +95 -0
- package/src/config/resolveLoader.ts +19 -0
- package/src/{rules/fileRules.js → config/rules/fileRules.ts} +1 -5
- package/src/{rules/scriptRules.js → config/rules/scriptRules.ts} +1 -8
- package/src/config/rules/styleRules.ts +38 -0
- package/src/index.ts +10 -9
- package/src/utils/fs.ts +13 -0
- package/src/utils/index.ts +1 -0
- package/dist/config/configFactory.d.ts +0 -7
- package/dist/config/configFactory.d.ts.map +0 -1
- package/dist/config/configFactory.js +0 -51
- package/dist/config/devServers.d.ts +0 -35
- package/dist/config/devServers.d.ts.map +0 -1
- package/dist/config/devServers.js +0 -67
- package/dist/config/postcss.config.d.ts +0 -2
- package/dist/config/postcss.config.d.ts.map +0 -1
- package/dist/config/postcss.config.js +0 -8
- package/dist/config/utils.d.ts +0 -20
- package/dist/config/utils.d.ts.map +0 -1
- package/dist/config/utils.js +0 -77
- package/dist/config/webpack.common.d.ts +0 -68
- package/dist/config/webpack.common.d.ts.map +0 -1
- package/dist/config/webpack.common.js +0 -106
- package/dist/config/webpack.dev.d.ts +0 -68
- package/dist/config/webpack.dev.d.ts.map +0 -1
- package/dist/config/webpack.dev.js +0 -31
- package/dist/config/webpack.prod.d.ts +0 -68
- package/dist/config/webpack.prod.d.ts.map +0 -1
- package/dist/config/webpack.prod.js +0 -43
- package/dist/rules/fileRules.d.ts.map +0 -1
- package/dist/rules/scriptRules.d.ts.map +0 -1
- package/dist/rules/styleRules.d.ts.map +0 -1
- package/dist/rules/styleRules.js +0 -53
- package/public/cert/README.md +0 -17
- package/public/cert/localhost.crt +0 -25
- package/public/cert/localhost.key +0 -28
- package/src/config/configFactory.js +0 -56
- package/src/config/devServers.js +0 -73
- package/src/config/postcss.config.js +0 -8
- package/src/config/utils.js +0 -99
- package/src/config/webpack.common.js +0 -109
- package/src/config/webpack.dev.js +0 -32
- package/src/config/webpack.prod.js +0 -47
- package/src/rules/styleRules.js +0 -60
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,KAAK,aAAoB,QAAQ,kBAoB7C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const build = (compiler) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
6
|
+
const stats = yield new Promise((success, error) => {
|
|
7
|
+
compiler.run((err, result) => (err ? error(err) : success(result)));
|
|
8
|
+
});
|
|
9
|
+
if (stats.hasErrors()) {
|
|
10
|
+
const error = new Error('Build error');
|
|
11
|
+
error.stack = stats.toString('errors-only');
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
process.stdout.write(stats.toString({
|
|
15
|
+
colors: true,
|
|
16
|
+
modules: false,
|
|
17
|
+
children: false,
|
|
18
|
+
chunks: false,
|
|
19
|
+
chunkModules: false,
|
|
20
|
+
}) + '\n\n');
|
|
21
|
+
});
|
|
22
|
+
exports.build = build;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGvD,eAAO,MAAM,GAAG,aAAoB,QAAQ,UAAU,aAAa,kBAGlE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dev = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const webpack_dev_server_1 = tslib_1.__importDefault(require("webpack-dev-server"));
|
|
6
|
+
const dev = (compiler, config) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
+
const server = new webpack_dev_server_1.default(config.devServer, compiler);
|
|
8
|
+
yield server.start();
|
|
9
|
+
});
|
|
10
|
+
exports.dev = dev;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devServer.d.ts","sourceRoot":"","sources":["../../src/config/devServer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAiC7C,eAAO,MAAM,SAAS,QAAS,YAAY,KAAG,aAAa,CAAC,WAAW,CAkDtE,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.devServer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const portfinder_sync_1 = tslib_1.__importDefault(require("portfinder-sync"));
|
|
8
|
+
const getPort = (packageJson) => { var _a; return portfinder_sync_1.default.getPort(((_a = packageJson.config) === null || _a === void 0 ? void 0 : _a.PORT) || process.env.PORT || 9000); };
|
|
9
|
+
const getServer = (isHTTPS = false) => {
|
|
10
|
+
if (isHTTPS) {
|
|
11
|
+
const certDir = (0, node_path_1.resolve)(__dirname, '../../cert/');
|
|
12
|
+
const cert = (0, node_path_1.resolve)(certDir, 'localhost.crt');
|
|
13
|
+
const key = (0, node_path_1.resolve)(certDir, 'localhost.key');
|
|
14
|
+
if ((0, node_fs_1.existsSync)(cert) && (0, node_fs_1.existsSync)(key)) {
|
|
15
|
+
return {
|
|
16
|
+
type: 'https',
|
|
17
|
+
options: {
|
|
18
|
+
cert: (0, node_fs_1.readFileSync)(cert),
|
|
19
|
+
key: (0, node_fs_1.readFileSync)(key),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
console.warn(`Could not load certificates from ${certDir}. Falling back to HTTP.`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
type: 'http',
|
|
29
|
+
options: {},
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const convertWsEndpointToHTTP = (endpoint = '', socketExt) => endpoint.replace(/^ws(s)?:\/\//, 'http$1://').replace(`/${socketExt}`, '');
|
|
33
|
+
const devServer = (ctx) => {
|
|
34
|
+
const { cli: { isDev, options: { open, https }, }, dirs: { cwd }, env: { isCI }, pkg, } = ctx;
|
|
35
|
+
if (!isDev) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const port = getPort(pkg);
|
|
39
|
+
const socketExt = process.env.SOCKET_EXT || 'gwf';
|
|
40
|
+
const target = convertWsEndpointToHTTP(process.env.API_HOST, socketExt);
|
|
41
|
+
return {
|
|
42
|
+
open: open && !isCI,
|
|
43
|
+
historyApiFallback: true,
|
|
44
|
+
allowedHosts: 'all',
|
|
45
|
+
host: 'localhost',
|
|
46
|
+
port,
|
|
47
|
+
server: getServer(https),
|
|
48
|
+
client: {
|
|
49
|
+
overlay: {
|
|
50
|
+
runtimeErrors: false,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
proxy: [
|
|
54
|
+
{
|
|
55
|
+
context: [`/${socketExt}/**`, '/sso/**'],
|
|
56
|
+
target,
|
|
57
|
+
secure: false,
|
|
58
|
+
changeOrigin: true,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
headers: {
|
|
62
|
+
'Access-Control-Allow-Origin': '*',
|
|
63
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
64
|
+
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
|
|
65
|
+
},
|
|
66
|
+
static: [
|
|
67
|
+
{
|
|
68
|
+
directory: (0, node_path_1.resolve)(cwd, './public'),
|
|
69
|
+
publicPath: '/',
|
|
70
|
+
watch: true,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
exports.devServer = devServer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/config/entry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,eAAO,MAAM,KAAK,QAAS,YAAY,KAAG,aAAa,CAAC,OAAO,CAkB9D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entry = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const federation_1 = require("./federation");
|
|
6
|
+
const entry = (ctx) => {
|
|
7
|
+
const { dirs: { cwd }, config: { serviceWorker }, } = ctx;
|
|
8
|
+
const main = (0, federation_1.federatedIndexExists)()
|
|
9
|
+
? (0, federation_1.resolveFederatedIndex)()
|
|
10
|
+
: (0, node_path_1.resolve)(cwd, './src/' + 'index.ts');
|
|
11
|
+
if (serviceWorker === null || serviceWorker === void 0 ? void 0 : serviceWorker.registration) {
|
|
12
|
+
return {
|
|
13
|
+
main,
|
|
14
|
+
swRegistration: (0, node_path_1.resolve)(cwd, './src/' + serviceWorker.registration),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return main;
|
|
18
|
+
};
|
|
19
|
+
exports.entry = entry;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PackageJson } from 'pkg-types';
|
|
2
|
+
import { container } from 'webpack';
|
|
3
|
+
type ModuleFederationPluginOptions = ConstructorParameters<typeof container.ModuleFederationPlugin>[0];
|
|
4
|
+
export declare const getFederatedPkgName: (pkgName: any) => any;
|
|
5
|
+
export declare const resolveFederatedIndex: () => string;
|
|
6
|
+
export declare const federatedIndexExists: () => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* TODO: Add prod version logic
|
|
9
|
+
*/
|
|
10
|
+
export declare const getRemoteEntryUrl: (port: any, host?: string) => string;
|
|
11
|
+
export declare const getRemoteEntry: (name: any, port: any, host?: string) => string;
|
|
12
|
+
export declare const resolveFederationOptions: (options: ModuleFederationPluginOptions, pkg: PackageJson) => ModuleFederationPluginOptions;
|
|
13
|
+
export declare const getFederationPlugins: (federatedIndexPresent: boolean, rootElement: string, options: ModuleFederationPluginOptions, pkg: PackageJson) => any[];
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=federation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation.d.ts","sourceRoot":"","sources":["../../src/config/federation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,KAAK,6BAA6B,GAAG,qBAAqB,CACxD,OAAO,SAAS,CAAC,sBAAsB,CACxC,CAAC,CAAC,CAAC,CAAC;AAIL,eAAO,MAAM,mBAAmB,uBAM/B,CAAC;AAIF,eAAO,MAAM,qBAAqB,cAA+C,CAAC;AAElF,eAAO,MAAM,oBAAoB,eAGhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,sCACmB,CAAC;AAElD,eAAO,MAAM,cAAc,iDACiB,CAAC;AAE7C,eAAO,MAAM,wBAAwB,YAC1B,6BAA6B,OACjC,WAAW,KACf,6BAoBF,CAAC;AAEF,eAAO,MAAM,oBAAoB,0BACR,OAAO,eACjB,MAAM,WACV,6BAA6B,OACjC,WAAW,UAoBV,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFederationPlugins = exports.resolveFederationOptions = exports.getRemoteEntry = exports.getRemoteEntryUrl = exports.federatedIndexExists = exports.resolveFederatedIndex = exports.getFederatedPkgName = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const dashboard_plugin_1 = tslib_1.__importDefault(require("@module-federation/dashboard-plugin"));
|
|
8
|
+
const camel_case_1 = require("camel-case");
|
|
9
|
+
const html_webpack_plugin_1 = tslib_1.__importDefault(require("html-webpack-plugin"));
|
|
10
|
+
const webpack_1 = require("webpack");
|
|
11
|
+
const { ModuleFederationPlugin } = webpack_1.container;
|
|
12
|
+
const remoteEntryFilename = 'remoteEntry.js';
|
|
13
|
+
const getFederatedPkgName = (pkgName) => {
|
|
14
|
+
try {
|
|
15
|
+
return (0, camel_case_1.camelCase)(pkgName.split('/').pop());
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return pkgName;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.getFederatedPkgName = getFederatedPkgName;
|
|
22
|
+
const federatedIndex = './src/index.federated.ts';
|
|
23
|
+
const resolveFederatedIndex = () => (0, node_path_1.resolve)(process.cwd(), federatedIndex);
|
|
24
|
+
exports.resolveFederatedIndex = resolveFederatedIndex;
|
|
25
|
+
const federatedIndexExists = () => {
|
|
26
|
+
const federatedIndexPath = (0, exports.resolveFederatedIndex)();
|
|
27
|
+
return (0, node_fs_1.existsSync)(federatedIndexPath);
|
|
28
|
+
};
|
|
29
|
+
exports.federatedIndexExists = federatedIndexExists;
|
|
30
|
+
/**
|
|
31
|
+
* TODO: Add prod version logic
|
|
32
|
+
*/
|
|
33
|
+
const getRemoteEntryUrl = (port, host = 'localhost') => `http://${host}:${port}/${remoteEntryFilename}`;
|
|
34
|
+
exports.getRemoteEntryUrl = getRemoteEntryUrl;
|
|
35
|
+
const getRemoteEntry = (name, port, host = 'localhost') => `${name}@${(0, exports.getRemoteEntryUrl)(port, host)}`;
|
|
36
|
+
exports.getRemoteEntry = getRemoteEntry;
|
|
37
|
+
const resolveFederationOptions = (options = {}, pkg) => {
|
|
38
|
+
const { name, exposes: mfExposes = {}, remotes: mfRemotes = {}, shared: mfShared = {} } = options;
|
|
39
|
+
const exposes = Object.assign({ './index': federatedIndex }, mfExposes);
|
|
40
|
+
const shared = Object.assign(Object.assign({}, pkg.dependencies), mfShared);
|
|
41
|
+
return {
|
|
42
|
+
name: name || (0, exports.getFederatedPkgName)(pkg.name),
|
|
43
|
+
filename: remoteEntryFilename,
|
|
44
|
+
remotes: mfRemotes,
|
|
45
|
+
exposes,
|
|
46
|
+
shared,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
exports.resolveFederationOptions = resolveFederationOptions;
|
|
50
|
+
const getFederationPlugins = (federatedIndexPresent, rootElement, options, pkg) => federatedIndexPresent
|
|
51
|
+
? [
|
|
52
|
+
new html_webpack_plugin_1.default({
|
|
53
|
+
title: `${pkg.description} (Federated)`,
|
|
54
|
+
template: (0, node_path_1.resolve)(__dirname, '../../public/info.ejs'),
|
|
55
|
+
filename: rootElement ? 'info.html' : 'index.html',
|
|
56
|
+
inject: false,
|
|
57
|
+
// Passing arbitrary data to the template for display
|
|
58
|
+
moduleFederationDetails: JSON.stringify(options, undefined, 2),
|
|
59
|
+
minify: false,
|
|
60
|
+
}),
|
|
61
|
+
new ModuleFederationPlugin(options),
|
|
62
|
+
process.env.FEDERATION_DASHABORD_URL &&
|
|
63
|
+
new dashboard_plugin_1.default({
|
|
64
|
+
dashboardURL: `${process.env.FEDERATION_DASHABORD_URL}/api/update`,
|
|
65
|
+
publishVersion: pkg.version,
|
|
66
|
+
}),
|
|
67
|
+
]
|
|
68
|
+
: [];
|
|
69
|
+
exports.getFederationPlugins = getFederationPlugins;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BuildContext } from '@genesislcap/build-kit';
|
|
2
|
+
import type { Configuration } from 'webpack';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param ctx Build context
|
|
6
|
+
* @returns Webpack config
|
|
7
|
+
*/
|
|
8
|
+
export declare const getConfig: (ctx: BuildContext) => Configuration;
|
|
9
|
+
//# sourceMappingURL=getConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfig.d.ts","sourceRoot":"","sources":["../../src/config/getConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAS7C;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAS,YAAY,KAAG,aAiC7C,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConfig = void 0;
|
|
4
|
+
const devServer_1 = require("./devServer");
|
|
5
|
+
const entry_1 = require("./entry");
|
|
6
|
+
const module_1 = require("./module");
|
|
7
|
+
const optimization_1 = require("./optimization");
|
|
8
|
+
const output_1 = require("./output");
|
|
9
|
+
const plugins_1 = require("./plugins");
|
|
10
|
+
const resolveLoader_1 = require("./resolveLoader");
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param ctx Build context
|
|
14
|
+
* @returns Webpack config
|
|
15
|
+
*/
|
|
16
|
+
const getConfig = (ctx) => {
|
|
17
|
+
const { cli: { isDev }, config: { webpack }, } = ctx;
|
|
18
|
+
return {
|
|
19
|
+
entry: (0, entry_1.entry)(ctx),
|
|
20
|
+
mode: isDev ? 'development' : 'production',
|
|
21
|
+
// Be aware of CSP if changing this to eval: https://github.com/symfony/webpack-encore/issues/695
|
|
22
|
+
devtool: isDev ? 'inline-source-map' : 'source-map',
|
|
23
|
+
devServer: (0, devServer_1.devServer)(ctx),
|
|
24
|
+
optimization: (0, optimization_1.optimization)(ctx),
|
|
25
|
+
plugins: (0, plugins_1.plugins)(ctx),
|
|
26
|
+
output: (0, output_1.output)(ctx),
|
|
27
|
+
resolve: {
|
|
28
|
+
extensions: ['.ts', '.js'],
|
|
29
|
+
modules: ['node_modules'],
|
|
30
|
+
},
|
|
31
|
+
resolveLoader: (0, resolveLoader_1.resolveLoader)(ctx),
|
|
32
|
+
module: (0, module_1.moduleConfig)(ctx),
|
|
33
|
+
experiments: {
|
|
34
|
+
topLevelAwait: true,
|
|
35
|
+
lazyCompilation: false,
|
|
36
|
+
},
|
|
37
|
+
performance: {
|
|
38
|
+
hints: false,
|
|
39
|
+
maxEntrypointSize: 512000,
|
|
40
|
+
maxAssetSize: 512000,
|
|
41
|
+
},
|
|
42
|
+
target: webpack === null || webpack === void 0 ? void 0 : webpack.target,
|
|
43
|
+
node: webpack === null || webpack === void 0 ? void 0 : webpack.node,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.getConfig = getConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/config/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAM7C,eAAO,MAAM,YAAY,QAAS,YAAY,KAAG,aAAa,CAAC,QAAQ,CAarE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.moduleConfig = void 0;
|
|
4
|
+
const fileRules_1 = require("./rules/fileRules");
|
|
5
|
+
const scriptRules_1 = require("./rules/scriptRules");
|
|
6
|
+
const styleRules_1 = require("./rules/styleRules");
|
|
7
|
+
// module is reserved keyword in CommonJS
|
|
8
|
+
const moduleConfig = (ctx) => ({
|
|
9
|
+
rules: [
|
|
10
|
+
scriptRules_1.appScriptRules.typescript(),
|
|
11
|
+
// Files
|
|
12
|
+
fileRules_1.appFileRules.fonts(),
|
|
13
|
+
fileRules_1.appFileRules.html(),
|
|
14
|
+
fileRules_1.appFileRules.images(),
|
|
15
|
+
// Styles
|
|
16
|
+
styleRules_1.appStyleRules.headCss(),
|
|
17
|
+
styleRules_1.appStyleRules.css(),
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
exports.moduleConfig = moduleConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimization.d.ts","sourceRoot":"","sources":["../../src/config/optimization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAa7C,eAAO,MAAM,YAAY,QAAS,YAAY,KAAG,aAAa,CAAC,cAAc,CA6B5E,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.optimization = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
6
|
+
const vendorCacheGroup = {
|
|
7
|
+
vendor: {
|
|
8
|
+
test: /[\\/]node_modules[\\/]/,
|
|
9
|
+
name: (module) => {
|
|
10
|
+
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
|
|
11
|
+
// npm package names are URL-safe, but some servers don't like @ symbols
|
|
12
|
+
return `npm.${packageName.replace('@', '')}`;
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const optimization = (ctx) => {
|
|
17
|
+
const { config: { webpack }, cli: { isDev }, } = ctx;
|
|
18
|
+
// user-supplied custom config
|
|
19
|
+
if (typeof (webpack === null || webpack === void 0 ? void 0 : webpack.optimization) === 'function') {
|
|
20
|
+
return webpack.optimization({ isDev });
|
|
21
|
+
}
|
|
22
|
+
// defaults
|
|
23
|
+
return isDev
|
|
24
|
+
? {
|
|
25
|
+
usedExports: false,
|
|
26
|
+
minimize: false,
|
|
27
|
+
}
|
|
28
|
+
: {
|
|
29
|
+
usedExports: true,
|
|
30
|
+
minimize: true,
|
|
31
|
+
minimizer: [new terser_webpack_plugin_1.default()],
|
|
32
|
+
splitChunks: {
|
|
33
|
+
chunks: 'all',
|
|
34
|
+
maxInitialRequests: 100,
|
|
35
|
+
cacheGroups: Object.assign({}, vendorCacheGroup),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.optimization = optimization;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/config/output.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAqB7C,eAAO,MAAM,MAAM,QAAS,YAAY,KAAG,aAAa,CAAC,QAAQ,CAiBhE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.output = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
/**
|
|
6
|
+
* Switching the '/' instead of 'auto', as webpack and perhaps the html-webpack-plugin seem to get confused over
|
|
7
|
+
* mime types, and this can block deep linking. Reading through the 'Practical Module Federation' guide, we may need
|
|
8
|
+
* to revisit this, dev v prod, resolving remotes.
|
|
9
|
+
*/
|
|
10
|
+
const publicPath = typeof process.env.PUBLIC_PATH !== 'undefined' ? process.env.PUBLIC_PATH : '/';
|
|
11
|
+
const defaultGetters = {
|
|
12
|
+
file: ({ isDev }) => (isDev ? '[name].js' : '[name].[contenthash].js'),
|
|
13
|
+
chunk: ({ isDev }) => (isDev ? '[name].[id].js' : '[name].[id].[contenthash].js'),
|
|
14
|
+
sourceMap: ({ isDev }) => (isDev ? '[name].js.map' : '[name].[contenthash].js.map'),
|
|
15
|
+
};
|
|
16
|
+
const filenameGetters = (config = {}) => ({
|
|
17
|
+
file: config.file || defaultGetters.file,
|
|
18
|
+
chunk: config.chunk || defaultGetters.chunk,
|
|
19
|
+
sourceMap: config.sourceMap || defaultGetters.sourceMap,
|
|
20
|
+
});
|
|
21
|
+
const output = (ctx) => {
|
|
22
|
+
const { cli: { isDev }, dirs: { cwd }, config: { webpack }, } = ctx;
|
|
23
|
+
const getters = filenameGetters(webpack === null || webpack === void 0 ? void 0 : webpack.filenames);
|
|
24
|
+
return {
|
|
25
|
+
strictModuleErrorHandling: true,
|
|
26
|
+
strictModuleExceptionHandling: true,
|
|
27
|
+
path: (0, node_path_1.resolve)(cwd, './dist'),
|
|
28
|
+
publicPath,
|
|
29
|
+
filename: getters.file({ isDev }),
|
|
30
|
+
chunkFilename: getters.chunk({ isDev }),
|
|
31
|
+
sourceMapFilename: getters.sourceMap({ isDev }),
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.output = output;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/config/plugins.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAK3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAiB7C,eAAO,MAAM,OAAO,QAAS,YAAY,KAAG,aAAa,CAAC,SAAS,CAsElE,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.plugins = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const build_kit_1 = require("@genesislcap/build-kit");
|
|
8
|
+
const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
|
|
9
|
+
const html_webpack_plugin_1 = tslib_1.__importDefault(require("html-webpack-plugin"));
|
|
10
|
+
const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
|
|
11
|
+
const webpack_1 = require("webpack");
|
|
12
|
+
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
13
|
+
const webpack_pwa_manifest_1 = tslib_1.__importDefault(require("webpack-pwa-manifest"));
|
|
14
|
+
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
15
|
+
const workbox_webpack_plugin_1 = require("workbox-webpack-plugin");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
const federation_1 = require("./federation");
|
|
18
|
+
const getTemplate = (cwd) => {
|
|
19
|
+
const templateApp = (0, node_path_1.resolve)(cwd, 'public/index.ejs');
|
|
20
|
+
const templateDefault = (0, node_path_1.resolve)(__dirname, '../public/index.ejs');
|
|
21
|
+
const template = (0, node_fs_1.existsSync)(templateApp) ? templateApp : templateDefault;
|
|
22
|
+
console.log(`Using index template: ${template}`);
|
|
23
|
+
return template;
|
|
24
|
+
};
|
|
25
|
+
const plugins = (ctx) => {
|
|
26
|
+
const { cli: { isAnalyze }, dirs: { cwd }, config: { serviceWorker, pwa, federation, app: { rootElement }, }, pkg, } = ctx;
|
|
27
|
+
const federatedIndexPresent = (0, federation_1.federatedIndexExists)();
|
|
28
|
+
const moduleFederationOptions = (0, federation_1.resolveFederationOptions)(federation, pkg);
|
|
29
|
+
return [
|
|
30
|
+
new copy_webpack_plugin_1.default({
|
|
31
|
+
patterns: [
|
|
32
|
+
{
|
|
33
|
+
from: (0, node_path_1.resolve)(__dirname, '../../public'),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
}),
|
|
37
|
+
new webpack_1.DefinePlugin({
|
|
38
|
+
API_HOST: JSON.stringify(process.env.API_HOST),
|
|
39
|
+
DEFAULT_ORGANISATION: JSON.stringify(process.env.DEFAULT_ORGANISATION),
|
|
40
|
+
DEFAULT_USER: JSON.stringify(process.env.DEFAULT_USER),
|
|
41
|
+
DEFAULT_PASSWORD: JSON.stringify(process.env.DEFAULT_PASSWORD),
|
|
42
|
+
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
|
|
43
|
+
FORCE_HTTP: JSON.stringify(process.env.FORCE_HTTP),
|
|
44
|
+
HTTP_CONFIG: JSON.stringify((0, utils_1.readFile)(process.env.HTTP_CONFIG_PATH)),
|
|
45
|
+
SOCKET_EXT: JSON.stringify(process.env.SOCKET_EXT),
|
|
46
|
+
}),
|
|
47
|
+
new webpackbar_1.default(),
|
|
48
|
+
new mini_css_extract_plugin_1.default(),
|
|
49
|
+
(rootElement || !federatedIndexPresent) &&
|
|
50
|
+
new html_webpack_plugin_1.default({
|
|
51
|
+
title: `${pkg.description}`,
|
|
52
|
+
template: getTemplate(cwd),
|
|
53
|
+
customElementTagName: rootElement,
|
|
54
|
+
minify: false,
|
|
55
|
+
}),
|
|
56
|
+
...(0, federation_1.getFederationPlugins)(federatedIndexPresent, rootElement, moduleFederationOptions, pkg),
|
|
57
|
+
isAnalyze &&
|
|
58
|
+
new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
|
|
59
|
+
reportTitle: `Webpack Visualizer`,
|
|
60
|
+
reportFilename: (0, node_path_1.join)(cwd, './dist', 'webpack.stats.html'),
|
|
61
|
+
analyzerMode: 'static',
|
|
62
|
+
openAnalyzer: false,
|
|
63
|
+
}),
|
|
64
|
+
pwa &&
|
|
65
|
+
new webpack_pwa_manifest_1.default(Object.assign(Object.assign({}, (0, build_kit_1.objToSnakeCase)(pwa)), { name: pwa.name, icons: Array.isArray(pwa.icons) &&
|
|
66
|
+
pwa.icons.map((icon) => ({
|
|
67
|
+
sizes: icon.sizes,
|
|
68
|
+
src: (0, node_path_1.resolve)(cwd, icon.src),
|
|
69
|
+
})) })),
|
|
70
|
+
serviceWorker &&
|
|
71
|
+
new workbox_webpack_plugin_1.InjectManifest({
|
|
72
|
+
swSrc: './src/' + serviceWorker.worker,
|
|
73
|
+
swDest: serviceWorker.assetName,
|
|
74
|
+
exclude: serviceWorker.exclude,
|
|
75
|
+
maximumFileSizeToCacheInBytes: serviceWorker.maximumFileSizeToCache,
|
|
76
|
+
}),
|
|
77
|
+
].filter(Boolean);
|
|
78
|
+
};
|
|
79
|
+
exports.plugins = plugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveLoader.d.ts","sourceRoot":"","sources":["../../src/config/resolveLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,aAAa,QAAS,YAAY,KAAG,aAAa,CAAC,eAAe,CAc9E,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveLoader = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const resolveLoader = (ctx) => {
|
|
6
|
+
const { dirs: { cwd, workspace }, } = ctx;
|
|
7
|
+
return {
|
|
8
|
+
modules: [
|
|
9
|
+
// webpack-builder node_modules
|
|
10
|
+
(0, node_path_1.resolve)(__dirname, '../../node_modules'),
|
|
11
|
+
// workspace folder node_modules (if set)
|
|
12
|
+
workspace ? (0, node_path_1.resolve)(workspace, 'node_modules') : '',
|
|
13
|
+
// package node_modules
|
|
14
|
+
(0, node_path_1.resolve)(cwd, 'node_modules'),
|
|
15
|
+
].filter(Boolean),
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.resolveLoader = resolveLoader;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export declare const appFileRules: {
|
|
2
|
+
fonts: () => {
|
|
3
3
|
test: RegExp;
|
|
4
4
|
type: string;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
html: () => {
|
|
7
7
|
test: RegExp;
|
|
8
8
|
use: {
|
|
9
9
|
loader: string;
|
|
10
10
|
}[];
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
images: () => {
|
|
13
13
|
test: RegExp;
|
|
14
14
|
type: string;
|
|
15
15
|
};
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
//# sourceMappingURL=fileRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileRules.d.ts","sourceRoot":"","sources":["../../../src/config/rules/fileRules.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;CAiBxB,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* eslint prefer-named-capture-group: "off" */
|
|
2
3
|
// In this config named capturing isn't desired.
|
|
3
4
|
// May cause adverse affects with webpack.
|
|
4
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.appFileRules = void 0;
|
|
7
|
+
exports.appFileRules = {
|
|
5
8
|
fonts: () => ({
|
|
6
9
|
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
7
10
|
type: 'asset/resource',
|
|
@@ -19,6 +22,3 @@ const appFileRules = {
|
|
|
19
22
|
type: 'asset/resource',
|
|
20
23
|
}),
|
|
21
24
|
};
|
|
22
|
-
module.exports = {
|
|
23
|
-
appFileRules,
|
|
24
|
-
};
|