@servicetitan/startup 24.4.0 → 25.1.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/cli/utils/bundle.d.ts.map +1 -1
- package/dist/cli/utils/bundle.js +54 -48
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/utils/get-package-data.d.ts +1 -0
- package/dist/utils/get-package-data.d.ts.map +1 -1
- package/dist/utils/get-package-data.js +1 -0
- package/dist/utils/get-package-data.js.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +28 -3
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -1
- package/package.json +7 -7
- package/src/cli/commands/__tests__/styles-check.test.ts +5 -1
- package/src/cli/utils/__tests__/bundle.test.ts +2 -2
- package/src/cli/utils/bundle.ts +55 -55
- package/src/utils/__tests__/get-package-data.test.ts +5 -1
- package/src/utils/get-package-data.ts +2 -0
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +5 -1
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +5 -1
- package/src/webpack/__tests__/create-webpack-config.test.ts +44 -8
- package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +32 -6
- package/src/webpack/configs/utils/__tests__/generate-metadata.test.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/bundle.ts"],"names":[],"mappings":"AAWA,UAAU,OAAO;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAWD,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAChE,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAElE,wBAAsB,MAAM,CAAC,OAAO,GAAE,OAAY,
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/bundle.ts"],"names":[],"mappings":"AAWA,UAAU,OAAO;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAWD,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAChE,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAElE,wBAAsB,MAAM,CAAC,OAAO,GAAE,OAAY,gCAwBjD;AAED,wBAAsB,WAAW,CAAC,OAAO,GAAE,OAAY,gCA0CtD"}
|
package/dist/cli/utils/bundle.js
CHANGED
|
@@ -49,21 +49,6 @@ function bundle() {
|
|
|
49
49
|
const fallback = `./${exports.webpackProdConfigFileName}`;
|
|
50
50
|
const config = readWebpackConfig(Object.assign(Object.assign({}, options), { fallback }));
|
|
51
51
|
const { buildStat, codeCoverage, esbuild, experimentalBundlers } = options;
|
|
52
|
-
const run = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const compiler = (0, webpack_1.default)(config);
|
|
54
|
-
const stats = yield new Promise((resolve, reject) => {
|
|
55
|
-
compiler.run((error, stats) => {
|
|
56
|
-
if (!stats || error) {
|
|
57
|
-
return reject(error !== null && error !== void 0 ? error : new Error('Something went wrong.'));
|
|
58
|
-
}
|
|
59
|
-
if (stats.hasErrors()) {
|
|
60
|
-
return reject(stats.toString('errors-only'));
|
|
61
|
-
}
|
|
62
|
-
compiler.close(() => resolve(stats));
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
process.stdout.write(stats.toString(config.stats) + '\n');
|
|
66
|
-
});
|
|
67
52
|
const webpackOptions = { name, buildStat, codeCoverage, esbuild, experimentalBundlers };
|
|
68
53
|
if ((0, utils_1.isWebComponent)()) {
|
|
69
54
|
const webpackConfig = {
|
|
@@ -86,45 +71,13 @@ function bundleWatch() {
|
|
|
86
71
|
const mode = 'development';
|
|
87
72
|
const config = readWebpackConfig(Object.assign(Object.assign({}, options), { fallback: `./${exports.webpackDevConfigFileName}` }));
|
|
88
73
|
const { codeCoverage, esbuild, experimentalBundlers } = options;
|
|
89
|
-
const runServe = (_a) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
var _b, _c;
|
|
91
|
-
var { devServer = {} } = _a, config = __rest(_a, ["devServer"]);
|
|
92
|
-
const compiler = (0, webpack_1.default)(config);
|
|
93
|
-
const host = (_b = devServer.host) !== null && _b !== void 0 ? _b : 'localhost';
|
|
94
|
-
const port = yield (0, portfinder_1.getPortPromise)({
|
|
95
|
-
port: (_c = devServer.port) !== null && _c !== void 0 ? _c : 8080,
|
|
96
|
-
host,
|
|
97
|
-
});
|
|
98
|
-
return new Promise((_0, reject) => {
|
|
99
|
-
const server = new webpack_dev_server_1.default(compiler, devServer);
|
|
100
|
-
server.listen(port, host, e => {
|
|
101
|
-
if (e) {
|
|
102
|
-
server.close(() => {
|
|
103
|
-
reject(e);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
const run = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
const compiler = (0, webpack_1.default)(config);
|
|
111
|
-
return new Promise((_0, reject) => {
|
|
112
|
-
const watching = compiler.watch({}, e => {
|
|
113
|
-
if (e) {
|
|
114
|
-
watching.close(() => {
|
|
115
|
-
reject(e);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
74
|
if ((0, utils_1.isWebComponent)()) {
|
|
122
75
|
const webpackConfig = {
|
|
123
76
|
configuration: Object.assign(Object.assign({}, config === null || config === void 0 ? void 0 : config.configuration), { mode }),
|
|
124
77
|
plugins: config === null || config === void 0 ? void 0 : config.plugins,
|
|
125
78
|
};
|
|
126
79
|
return Promise.all([
|
|
127
|
-
|
|
80
|
+
runWatch((0, webpack_2.createWebpackConfig)(webpackConfig, {
|
|
128
81
|
codeCoverage,
|
|
129
82
|
embed: true,
|
|
130
83
|
name,
|
|
@@ -152,4 +105,57 @@ function readConfig(relativePath) {
|
|
|
152
105
|
return require(path_1.default.resolve(relativePath));
|
|
153
106
|
}
|
|
154
107
|
}
|
|
108
|
+
function run(config) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const compiler = (0, webpack_1.default)(config);
|
|
111
|
+
const stats = yield new Promise((resolve, reject) => {
|
|
112
|
+
compiler.run((error, stats) => {
|
|
113
|
+
if (!stats || error) {
|
|
114
|
+
return reject(error !== null && error !== void 0 ? error : new Error('Something went wrong.'));
|
|
115
|
+
}
|
|
116
|
+
if (stats.hasErrors()) {
|
|
117
|
+
return reject(stats.toString('errors-only'));
|
|
118
|
+
}
|
|
119
|
+
compiler.close(() => resolve(stats));
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
process.stdout.write(stats.toString(config.stats) + '\n');
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function runServe(_a) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
var _b, _c;
|
|
128
|
+
var { devServer = {} } = _a, config = __rest(_a, ["devServer"]);
|
|
129
|
+
const compiler = (0, webpack_1.default)(config);
|
|
130
|
+
const host = (_b = devServer.host) !== null && _b !== void 0 ? _b : 'localhost';
|
|
131
|
+
const port = yield (0, portfinder_1.getPortPromise)({
|
|
132
|
+
port: (_c = devServer.port) !== null && _c !== void 0 ? _c : 8080,
|
|
133
|
+
host,
|
|
134
|
+
});
|
|
135
|
+
return new Promise((_0, reject) => {
|
|
136
|
+
const server = new webpack_dev_server_1.default(compiler, devServer);
|
|
137
|
+
server.listen(port, host, e => {
|
|
138
|
+
if (e) {
|
|
139
|
+
server.close(() => {
|
|
140
|
+
reject(e);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function runWatch(config) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const compiler = (0, webpack_1.default)(config);
|
|
150
|
+
return new Promise((_0, reject) => {
|
|
151
|
+
const watching = compiler.watch({}, e => {
|
|
152
|
+
if (e) {
|
|
153
|
+
watching.close(() => {
|
|
154
|
+
reject(e);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
155
161
|
//# sourceMappingURL=bundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/cli/utils/bundle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,oDAA4B;AAC5B,2CAA4C;AAE5C,sDAAiD;AACjD,4EAAkD;AAElD,uCAAkE;AAClE,2CAA+D;AAU/D,SAAS,OAAO;IACZ,MAAM,WAAW,GAAG,IAAA,sBAAc,GAAE;SAC/B,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,gBAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEnD,OAAO,GAAG,WAAW,IAAI,IAAI,EAAE,CAAC;AACpC,CAAC;AAEY,QAAA,wBAAwB,GAAG,uBAAuB,CAAC;AACnD,QAAA,yBAAyB,GAAG,wBAAwB,CAAC;AAElE,SAAsB,MAAM;yDAAC,UAAmB,EAAE;QAC9C,WAAG,C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C;YAEzD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;gBAC1B,IAAI,CAAC,EAAE,CAAC;oBACJ,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;wBACd,MAAM,CAAC,CAAC,CAAC,CAAC;oBACd,CAAC,CAAC,CAAC;gBACP,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,SAAe,QAAQ,CAAC,MAAqB;;QACzC,MAAM,QAAQ,GAAG,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC;QACjC,OAAO,IAAI,OAAO,CAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE;YACpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;gBACpC,IAAI,CAAC,EAAE,CAAC;oBACJ,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE;wBAChB,MAAM,CAAC,CAAC,CAAC,CAAC;oBACd,CAAC,CAAC,CAAC;gBACP,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-package-data.d.ts","sourceRoot":"","sources":["../../src/utils/get-package-data.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,IAAI;IAC9B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C,
|
|
1
|
+
{"version":3,"file":"get-package-data.d.ts","sourceRoot":"","sources":["../../src/utils/get-package-data.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,IAAI;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C,CAWA;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,OAYtF"}
|
|
@@ -6,6 +6,7 @@ function getPackageData() {
|
|
|
6
6
|
var _a, _b;
|
|
7
7
|
const packageJson = (0, read_json_1.readJson)('./package.json');
|
|
8
8
|
return {
|
|
9
|
+
name: packageJson.name,
|
|
9
10
|
dependencies: Object.assign(Object.assign({}, (0, read_json_1.readJson)('../../package.json').dependencies), packageJson.dependencies),
|
|
10
11
|
sharedDependencies: (_b = (_a = packageJson.cli) === null || _a === void 0 ? void 0 : _a.webpack) === null || _b === void 0 ? void 0 : _b['shared-dependencies'],
|
|
11
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-package-data.js","sourceRoot":"","sources":["../../src/utils/get-package-data.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,SAAgB,cAAc;;
|
|
1
|
+
{"version":3,"file":"get-package-data.js","sourceRoot":"","sources":["../../src/utils/get-package-data.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,SAAgB,cAAc;;IAK1B,MAAM,WAAW,GAAG,IAAA,oBAAQ,EAAC,gBAAgB,CAAC,CAAC;IAE/C,OAAO;QACH,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,YAAY,kCACL,IAAA,oBAAQ,EAAC,oBAAoB,CAAC,CAAC,YAAY,GAC3C,WAAW,CAAC,YAAY,CAC9B;QACD,kBAAkB,EAAE,MAAA,MAAA,WAAW,CAAC,GAAG,0CAAE,OAAO,0CAAG,qBAAqB,CAAC;KACxE,CAAC;AACN,CAAC;AAfD,wCAeC;AAED,SAAgB,2BAA2B,CAAC,UAAkB,EAAE,cAAuB;IACnF,IAAI,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,UAAU,eAAe,CAAC,CAAC;QAE1D,IAAI,OAAO,EAAE,CAAC;YACV,OAAO,OAAO,CAAC;QACnB,CAAC;IACL,CAAC;IAAC,WAAM,CAAC;QACL,aAAa;IACjB,CAAC;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC;AAZD,kEAYC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Context, Overrides } from '../types';
|
|
2
|
-
export declare function bundleAnalyzerPlugin(
|
|
2
|
+
export declare function bundleAnalyzerPlugin(context: Context, _: Overrides): any;
|
|
3
3
|
//# sourceMappingURL=bundle-analyser-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-analyser-plugin.d.ts","sourceRoot":"","sources":["../../../../src/webpack/configs/plugins/bundle-analyser-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"bundle-analyser-plugin.d.ts","sourceRoot":"","sources":["../../../../src/webpack/configs/plugins/bundle-analyser-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,OAUlE"}
|
|
@@ -7,14 +7,39 @@ exports.bundleAnalyzerPlugin = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
10
|
-
function bundleAnalyzerPlugin(
|
|
11
|
-
if (!buildStat) {
|
|
10
|
+
function bundleAnalyzerPlugin(context, _) {
|
|
11
|
+
if (!context.buildStat) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
return new BundleAnalyzerPlugin({
|
|
15
15
|
analyzerMode: 'static',
|
|
16
|
-
reportFilename: path_1.default.join(os_1.default.tmpdir(),
|
|
16
|
+
reportFilename: path_1.default.join(os_1.default.tmpdir(), getReportFileName(context)),
|
|
17
|
+
reportTitle: getReportTitle(context),
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
exports.bundleAnalyzerPlugin = bundleAnalyzerPlugin;
|
|
21
|
+
function getBundleType({ embed, isWebComponent }) {
|
|
22
|
+
if (isWebComponent) {
|
|
23
|
+
return embed ? 'light' : 'full';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function getReportFileName(context) {
|
|
27
|
+
const type = getBundleType(context);
|
|
28
|
+
const qualifier = type ? `-${type}` : '';
|
|
29
|
+
return `${context.packageData.name}${qualifier}-bundle-${Date.now()}.html`;
|
|
30
|
+
}
|
|
31
|
+
function getReportTitle(context) {
|
|
32
|
+
const unscopedName = context.packageData.name.replace(/^@[^/]+\//, '');
|
|
33
|
+
const type = getBundleType(context);
|
|
34
|
+
const qualifier = type ? ` (${type})` : '';
|
|
35
|
+
return `${unscopedName}${qualifier} ${formatDate(new Date())}`;
|
|
36
|
+
}
|
|
37
|
+
function formatDate(date) {
|
|
38
|
+
const yyyy = date.getFullYear();
|
|
39
|
+
const mm = date.getMonth() + 1;
|
|
40
|
+
const dd = date.getDate();
|
|
41
|
+
const HH = date.getHours();
|
|
42
|
+
const MM = date.getMinutes();
|
|
43
|
+
return `${yyyy}-${mm}-${dd} ${HH}:${MM}`;
|
|
44
|
+
}
|
|
20
45
|
//# sourceMappingURL=bundle-analyser-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-analyser-plugin.js","sourceRoot":"","sources":["../../../../src/webpack/configs/plugins/bundle-analyser-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,MAAM,oBAAoB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,oBAAoB,CAAC;AAGrF,SAAgB,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"bundle-analyser-plugin.js","sourceRoot":"","sources":["../../../../src/webpack/configs/plugins/bundle-analyser-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,MAAM,oBAAoB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,oBAAoB,CAAC;AAGrF,SAAgB,oBAAoB,CAAC,OAAgB,EAAE,CAAY;IAC/D,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO;IACX,CAAC;IAED,OAAO,IAAI,oBAAoB,CAAC;QAC5B,YAAY,EAAE,QAAQ;QACtB,cAAc,EAAE,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAClE,WAAW,EAAE,cAAc,CAAC,OAAO,CAAC;KACvC,CAAC,CAAC;AACP,CAAC;AAVD,oDAUC;AAED,SAAS,aAAa,CAAC,EAAE,KAAK,EAAE,cAAc,EAAW;IACrD,IAAI,cAAc,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IACpC,CAAC;AACL,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAgB;IACvC,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACzC,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,GAAG,SAAS,WAAW,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC;AAC/E,CAAC;AAED,SAAS,cAAc,CAAC,OAAgB;IACpC,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3C,OAAO,GAAG,YAAY,GAAG,SAAS,IAAI,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;AACnE,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC/B,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1B,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAC7B,OAAO,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/startup",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@babel/preset-env": "~7.24.8",
|
|
38
38
|
"@jest/core": "~29.7.0",
|
|
39
39
|
"@jest/types": "~29.6.3",
|
|
40
|
-
"@servicetitan/eslint-config": "
|
|
41
|
-
"@servicetitan/stylelint-config": "
|
|
40
|
+
"@servicetitan/eslint-config": "25.1.0",
|
|
41
|
+
"@servicetitan/stylelint-config": "25.1.0",
|
|
42
42
|
"@svgr/webpack": "^8.1.0",
|
|
43
43
|
"@swc/core": "1.6.13",
|
|
44
44
|
"@types/debug": "^4.1.12",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"css-loader": "~7.1.2",
|
|
50
50
|
"debug": "^4.3.5",
|
|
51
51
|
"deepmerge": "~4.3.1",
|
|
52
|
-
"esbuild-loader": "~4.2.
|
|
52
|
+
"esbuild-loader": "~4.2.2",
|
|
53
53
|
"eslint": "~8.57.0",
|
|
54
54
|
"execa": "~5.1.1",
|
|
55
55
|
"fork-ts-checker-webpack-plugin": "~9.0.2",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"portfinder": "~1.0.32",
|
|
73
73
|
"postcss": "~8.4.39",
|
|
74
74
|
"prettier": "~2.7.1",
|
|
75
|
-
"sass": "~1.77.
|
|
75
|
+
"sass": "~1.77.8",
|
|
76
76
|
"sass-loader": "~14.2.1",
|
|
77
77
|
"source-map-loader": "~5.0.0",
|
|
78
78
|
"string-width": "<5.0.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"typed-css-modules": "~0.9.1",
|
|
86
86
|
"typescript": "~5.4.5",
|
|
87
87
|
"username": "~5.1.0",
|
|
88
|
-
"webpack": "~5.
|
|
88
|
+
"webpack": "~5.93.0",
|
|
89
89
|
"webpack-assets-manifest": "~5.2.1",
|
|
90
90
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
91
91
|
"webpack-dev-server": "~3.11.2",
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"cli": {
|
|
106
106
|
"webpack": false
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "0274a11f080937b7433a5d09c901a2b8068c045d"
|
|
109
109
|
}
|
|
@@ -33,7 +33,11 @@ describe(`[startup] ${StylesCheck.name}`, () => {
|
|
|
33
33
|
jest.resetAllMocks();
|
|
34
34
|
jest.mocked(isBundle).mockReturnValue(true);
|
|
35
35
|
jest.mocked(getFolders).mockReturnValue({ source: 'src', destination: 'dist' });
|
|
36
|
-
jest.mocked(getPackageData).mockReturnValue({
|
|
36
|
+
jest.mocked(getPackageData).mockReturnValue({
|
|
37
|
+
name: '',
|
|
38
|
+
dependencies: {},
|
|
39
|
+
sharedDependencies: {},
|
|
40
|
+
});
|
|
37
41
|
jest.mocked(loadSharedDependencies).mockReturnValue({});
|
|
38
42
|
});
|
|
39
43
|
|
|
@@ -168,7 +168,7 @@ describe('[startup] Cli Utils', () => {
|
|
|
168
168
|
beforeEach(() => {
|
|
169
169
|
vol.fromJSON(webComponentFS());
|
|
170
170
|
jest.mocked(getFolders).mockReturnValue({ source, destination });
|
|
171
|
-
jest.mocked(getPackageData).mockReturnValue({ dependencies });
|
|
171
|
+
jest.mocked(getPackageData).mockReturnValue({ name: '', dependencies });
|
|
172
172
|
jest.mocked(loadSharedDependencies).mockReturnValue(sharedDependencies);
|
|
173
173
|
});
|
|
174
174
|
|
|
@@ -327,7 +327,7 @@ describe('[startup] Cli Utils', () => {
|
|
|
327
327
|
beforeEach(() => {
|
|
328
328
|
vol.fromJSON(webComponentFS());
|
|
329
329
|
jest.mocked(getFolders).mockReturnValue({ source, destination });
|
|
330
|
-
jest.mocked(getPackageData).mockReturnValue({ dependencies });
|
|
330
|
+
jest.mocked(getPackageData).mockReturnValue({ name: '', dependencies });
|
|
331
331
|
jest.mocked(loadSharedDependencies).mockReturnValue(sharedDependencies);
|
|
332
332
|
});
|
|
333
333
|
|
package/src/cli/utils/bundle.ts
CHANGED
|
@@ -38,26 +38,6 @@ export async function bundle(options: Options = {}) {
|
|
|
38
38
|
const config = readWebpackConfig({ ...options, fallback });
|
|
39
39
|
const { buildStat, codeCoverage, esbuild, experimentalBundlers } = options;
|
|
40
40
|
|
|
41
|
-
const run = async (config: Configuration) => {
|
|
42
|
-
const compiler = webpack(config);
|
|
43
|
-
|
|
44
|
-
const stats = await new Promise<webpack.Stats>((resolve, reject) => {
|
|
45
|
-
compiler.run((error, stats) => {
|
|
46
|
-
if (!stats || error) {
|
|
47
|
-
return reject(error ?? new Error('Something went wrong.'));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (stats.hasErrors()) {
|
|
51
|
-
return reject(stats.toString('errors-only'));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
compiler.close(() => resolve(stats));
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
process.stdout.write(stats.toString(config.stats) + '\n');
|
|
59
|
-
};
|
|
60
|
-
|
|
61
41
|
const webpackOptions = { name, buildStat, codeCoverage, esbuild, experimentalBundlers };
|
|
62
42
|
|
|
63
43
|
if (isWebComponent()) {
|
|
@@ -83,40 +63,6 @@ export async function bundleWatch(options: Options = {}) {
|
|
|
83
63
|
const config = readWebpackConfig({ ...options, fallback: `./${webpackDevConfigFileName}` });
|
|
84
64
|
const { codeCoverage, esbuild, experimentalBundlers } = options;
|
|
85
65
|
|
|
86
|
-
const runServe = async ({ devServer = {}, ...config }: Configuration) => {
|
|
87
|
-
const compiler = webpack(config);
|
|
88
|
-
const host = devServer.host ?? 'localhost';
|
|
89
|
-
const port = await getPortPromise({
|
|
90
|
-
port: devServer.port ?? 8080,
|
|
91
|
-
host,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return new Promise<void>((_0, reject) => {
|
|
95
|
-
const server = new WebpackDevServer(compiler, devServer);
|
|
96
|
-
|
|
97
|
-
server.listen(port, host, e => {
|
|
98
|
-
if (e) {
|
|
99
|
-
server.close(() => {
|
|
100
|
-
reject(e);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const run = async (config: Configuration) => {
|
|
108
|
-
const compiler = webpack(config);
|
|
109
|
-
return new Promise<void>((_0, reject) => {
|
|
110
|
-
const watching = compiler.watch({}, e => {
|
|
111
|
-
if (e) {
|
|
112
|
-
watching.close(() => {
|
|
113
|
-
reject(e);
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
|
|
120
66
|
if (isWebComponent()) {
|
|
121
67
|
const webpackConfig: Overrides = {
|
|
122
68
|
configuration: { ...config?.configuration, mode },
|
|
@@ -124,7 +70,7 @@ export async function bundleWatch(options: Options = {}) {
|
|
|
124
70
|
};
|
|
125
71
|
|
|
126
72
|
return Promise.all([
|
|
127
|
-
|
|
73
|
+
runWatch(
|
|
128
74
|
createWebpackConfig(webpackConfig, {
|
|
129
75
|
codeCoverage,
|
|
130
76
|
embed: true,
|
|
@@ -162,3 +108,57 @@ function readConfig(relativePath?: string): Record<string, any> | undefined {
|
|
|
162
108
|
return require(path.resolve(relativePath));
|
|
163
109
|
}
|
|
164
110
|
}
|
|
111
|
+
|
|
112
|
+
async function run(config: Configuration) {
|
|
113
|
+
const compiler = webpack(config);
|
|
114
|
+
|
|
115
|
+
const stats = await new Promise<webpack.Stats>((resolve, reject) => {
|
|
116
|
+
compiler.run((error, stats) => {
|
|
117
|
+
if (!stats || error) {
|
|
118
|
+
return reject(error ?? new Error('Something went wrong.'));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (stats.hasErrors()) {
|
|
122
|
+
return reject(stats.toString('errors-only'));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
compiler.close(() => resolve(stats));
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
process.stdout.write(stats.toString(config.stats) + '\n');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function runServe({ devServer = {}, ...config }: Configuration) {
|
|
133
|
+
const compiler = webpack(config);
|
|
134
|
+
const host = devServer.host ?? 'localhost';
|
|
135
|
+
const port = await getPortPromise({
|
|
136
|
+
port: devServer.port ?? 8080,
|
|
137
|
+
host,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return new Promise<void>((_0, reject) => {
|
|
141
|
+
const server = new WebpackDevServer(compiler, devServer);
|
|
142
|
+
|
|
143
|
+
server.listen(port, host, e => {
|
|
144
|
+
if (e) {
|
|
145
|
+
server.close(() => {
|
|
146
|
+
reject(e);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function runWatch(config: Configuration) {
|
|
154
|
+
const compiler = webpack(config);
|
|
155
|
+
return new Promise<void>((_0, reject) => {
|
|
156
|
+
const watching = compiler.watch({}, e => {
|
|
157
|
+
if (e) {
|
|
158
|
+
watching.close(() => {
|
|
159
|
+
reject(e);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
@@ -13,7 +13,10 @@ describe(`[startup] Utils`, () => {
|
|
|
13
13
|
beforeEach(() => {
|
|
14
14
|
packages = {
|
|
15
15
|
[ancestorPackageJson]: { dependencies: { foo: '1.0.0', bar: '2.0.0' } },
|
|
16
|
-
[packageJson]: {
|
|
16
|
+
[packageJson]: {
|
|
17
|
+
name: 'packageName',
|
|
18
|
+
dependencies: { foo: '1.1.0', baz: '3.0.0' },
|
|
19
|
+
},
|
|
17
20
|
};
|
|
18
21
|
jest.mocked(readJson).mockImplementation(path => packages[path] ?? {});
|
|
19
22
|
});
|
|
@@ -22,6 +25,7 @@ describe(`[startup] Utils`, () => {
|
|
|
22
25
|
|
|
23
26
|
test(`returns merged dependencies from ${packageJson} and ${ancestorPackageJson}`, () => {
|
|
24
27
|
expect(subject()).toEqual({
|
|
28
|
+
name: packages[packageJson].name,
|
|
25
29
|
dependencies: {
|
|
26
30
|
...packages[ancestorPackageJson].dependencies,
|
|
27
31
|
...packages[packageJson].dependencies,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { readJson } from './read-json';
|
|
2
2
|
|
|
3
3
|
export function getPackageData(): {
|
|
4
|
+
name: string;
|
|
4
5
|
dependencies: Record<string, string>;
|
|
5
6
|
sharedDependencies?: Record<string, string>;
|
|
6
7
|
} {
|
|
7
8
|
const packageJson = readJson('./package.json');
|
|
8
9
|
|
|
9
10
|
return {
|
|
11
|
+
name: packageJson.name,
|
|
10
12
|
dependencies: {
|
|
11
13
|
...readJson('../../package.json').dependencies,
|
|
12
14
|
...packageJson.dependencies,
|
|
@@ -70,7 +70,11 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
70
70
|
|
|
71
71
|
jest.mocked(getFolders).mockReturnValue({ source, destination });
|
|
72
72
|
jest.mocked(getModuleEntryPath).mockImplementation(name => `${name}/entryPath`);
|
|
73
|
-
jest.mocked(getPackageData).mockReturnValue({
|
|
73
|
+
jest.mocked(getPackageData).mockReturnValue({
|
|
74
|
+
name: '',
|
|
75
|
+
dependencies,
|
|
76
|
+
sharedDependencies,
|
|
77
|
+
});
|
|
74
78
|
jest.mocked(getPackageDependencyVersion).mockImplementation(
|
|
75
79
|
(_, defaultVersion) => defaultVersion
|
|
76
80
|
);
|
|
@@ -95,7 +95,11 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
95
95
|
|
|
96
96
|
jest.mocked(getCallerFile).mockReturnValue('');
|
|
97
97
|
jest.mocked(getFolders).mockReturnValue({ source, destination });
|
|
98
|
-
jest.mocked(getPackageData).mockReturnValue({
|
|
98
|
+
jest.mocked(getPackageData).mockReturnValue({
|
|
99
|
+
name: packageName,
|
|
100
|
+
dependencies: {},
|
|
101
|
+
sharedDependencies: {},
|
|
102
|
+
});
|
|
99
103
|
jest.mocked(getPackages).mockReturnValue([]);
|
|
100
104
|
jest.mocked(getTsConfig).mockReturnValue(tsConfig);
|
|
101
105
|
jest.mocked(isLegacyRoot).mockReturnValue(false);
|
|
@@ -118,7 +118,11 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
118
118
|
const prefix = location ? `${location.replace(/\W/g, '')}-` : '';
|
|
119
119
|
return { source: `${prefix}${source}`, destination };
|
|
120
120
|
});
|
|
121
|
-
jest.mocked(getPackageData).mockReturnValue({
|
|
121
|
+
jest.mocked(getPackageData).mockReturnValue({
|
|
122
|
+
name: packageName,
|
|
123
|
+
dependencies,
|
|
124
|
+
sharedDependencies,
|
|
125
|
+
});
|
|
122
126
|
jest.mocked(getPackageDependencyVersion).mockImplementation(
|
|
123
127
|
(_, defaultVersion) => defaultVersion
|
|
124
128
|
);
|
|
@@ -381,29 +385,61 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
381
385
|
jest.useFakeTimers(); // because filename includes timestamp
|
|
382
386
|
});
|
|
383
387
|
|
|
384
|
-
|
|
385
|
-
path.join(
|
|
388
|
+
function reportFilename(type?: string) {
|
|
389
|
+
return path.join(
|
|
390
|
+
os.tmpdir(),
|
|
391
|
+
`${packageName}${type ? `-${type}` : ''}-bundle-${Date.now()}.html`
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function reportTitle(type?: string) {
|
|
396
|
+
const date = new Date();
|
|
397
|
+
|
|
398
|
+
const timestamp = `${date.getFullYear()}-${
|
|
399
|
+
date.getMonth() + 1
|
|
400
|
+
}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`;
|
|
401
|
+
|
|
402
|
+
return `${packageName.replace('@servicetitan/', '')}${
|
|
403
|
+
type ? ` (${type})` : ''
|
|
404
|
+
} ${timestamp}`;
|
|
405
|
+
}
|
|
386
406
|
|
|
387
407
|
test('configures BundleAnalyzerPlugin plugin', () => {
|
|
388
408
|
expect(subject().plugins).toContainEqual(
|
|
389
409
|
new BundleAnalyzerPlugin({
|
|
390
410
|
analyzerMode: 'static',
|
|
391
|
-
reportFilename: reportFilename(
|
|
411
|
+
reportFilename: reportFilename(),
|
|
412
|
+
reportTitle: reportTitle(),
|
|
392
413
|
})
|
|
393
414
|
);
|
|
394
415
|
});
|
|
395
416
|
|
|
396
|
-
describe('when
|
|
397
|
-
beforeEach(() =>
|
|
417
|
+
describe('when package is web component', () => {
|
|
418
|
+
beforeEach(() => jest.mocked(isWebComponent).mockReturnValue(true));
|
|
398
419
|
|
|
399
|
-
test('
|
|
420
|
+
test('adds "full" to reportFilename and reportTitle', () => {
|
|
400
421
|
expect(subject().plugins).toContainEqual(
|
|
401
422
|
new BundleAnalyzerPlugin({
|
|
402
423
|
analyzerMode: 'static',
|
|
403
|
-
reportFilename: reportFilename('
|
|
424
|
+
reportFilename: reportFilename('full'),
|
|
425
|
+
reportTitle: reportTitle('full'),
|
|
404
426
|
})
|
|
405
427
|
);
|
|
406
428
|
});
|
|
429
|
+
|
|
430
|
+
describe('when embed option is set to true', () => {
|
|
431
|
+
beforeEach(() => setOptions({ embed: true }));
|
|
432
|
+
|
|
433
|
+
test('adds "light" to reportFilename and reportTitle', () => {
|
|
434
|
+
expect(subject().plugins).toContainEqual(
|
|
435
|
+
new BundleAnalyzerPlugin({
|
|
436
|
+
analyzerMode: 'static',
|
|
437
|
+
reportFilename: reportFilename('light'),
|
|
438
|
+
reportTitle: reportTitle('light'),
|
|
439
|
+
})
|
|
440
|
+
);
|
|
441
|
+
});
|
|
442
|
+
});
|
|
407
443
|
});
|
|
408
444
|
});
|
|
409
445
|
|
|
@@ -3,16 +3,42 @@ import os from 'os';
|
|
|
3
3
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
4
4
|
import { Context, Overrides } from '../types';
|
|
5
5
|
|
|
6
|
-
export function bundleAnalyzerPlugin(
|
|
7
|
-
if (!buildStat) {
|
|
6
|
+
export function bundleAnalyzerPlugin(context: Context, _: Overrides) {
|
|
7
|
+
if (!context.buildStat) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return new BundleAnalyzerPlugin({
|
|
12
12
|
analyzerMode: 'static',
|
|
13
|
-
reportFilename: path.join(
|
|
14
|
-
|
|
15
|
-
`report-${embed ? 'light' : 'full'}-bundle-${Date.now()}.html`
|
|
16
|
-
),
|
|
13
|
+
reportFilename: path.join(os.tmpdir(), getReportFileName(context)),
|
|
14
|
+
reportTitle: getReportTitle(context),
|
|
17
15
|
});
|
|
18
16
|
}
|
|
17
|
+
|
|
18
|
+
function getBundleType({ embed, isWebComponent }: Context) {
|
|
19
|
+
if (isWebComponent) {
|
|
20
|
+
return embed ? 'light' : 'full';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getReportFileName(context: Context) {
|
|
25
|
+
const type = getBundleType(context);
|
|
26
|
+
const qualifier = type ? `-${type}` : '';
|
|
27
|
+
return `${context.packageData.name}${qualifier}-bundle-${Date.now()}.html`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getReportTitle(context: Context) {
|
|
31
|
+
const unscopedName = context.packageData.name.replace(/^@[^/]+\//, '');
|
|
32
|
+
const type = getBundleType(context);
|
|
33
|
+
const qualifier = type ? ` (${type})` : '';
|
|
34
|
+
return `${unscopedName}${qualifier} ${formatDate(new Date())}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function formatDate(date: Date) {
|
|
38
|
+
const yyyy = date.getFullYear();
|
|
39
|
+
const mm = date.getMonth() + 1;
|
|
40
|
+
const dd = date.getDate();
|
|
41
|
+
const HH = date.getHours();
|
|
42
|
+
const MM = date.getMinutes();
|
|
43
|
+
return `${yyyy}-${mm}-${dd} ${HH}:${MM}`;
|
|
44
|
+
}
|
|
@@ -34,7 +34,7 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
34
34
|
context = {
|
|
35
35
|
destination,
|
|
36
36
|
name: pkg.name,
|
|
37
|
-
packageData: { dependencies: { foo: '1.0.1' } },
|
|
37
|
+
packageData: { name: pkg.name, dependencies: { foo: '1.0.1' } },
|
|
38
38
|
sharedDependencies: { react: 'SharedDependencies.React' },
|
|
39
39
|
};
|
|
40
40
|
});
|