@backstage/cli 0.28.0-next.2 → 0.29.0-next.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/CHANGELOG.md +95 -0
- package/config/jest.js +49 -25
- package/config/jestRejectNetworkRequests.js +59 -0
- package/config/nodeTransform.cjs +33 -0
- package/dist/commands/build/buildFrontend.cjs.js +11 -13
- package/dist/commands/build/command.cjs.js +5 -2
- package/dist/commands/buildWorkspace.cjs.js +1 -1
- package/dist/commands/index.cjs.js +9 -3
- package/dist/commands/repo/lint.cjs.js +23 -33
- package/dist/commands/repo/test.cjs.js +13 -32
- package/dist/commands/start/command.cjs.js +1 -0
- package/dist/commands/start/startBackend.cjs.js +23 -92
- package/dist/commands/start/startFrontend.cjs.js +6 -8
- package/dist/commands/versions/bump.cjs.js +9 -3
- package/dist/lib/bundler/bundle.cjs.js +5 -4
- package/dist/lib/bundler/config.cjs.js +75 -171
- package/dist/lib/bundler/hasReactDomClient.cjs.js +5 -1
- package/dist/lib/bundler/linkWorkspaces.cjs.js +31 -0
- package/dist/lib/bundler/optimization.cjs.js +10 -6
- package/dist/lib/bundler/server.cjs.js +47 -7
- package/dist/lib/bundler/transforms.cjs.js +7 -6
- package/dist/lib/cache/SuccessCache.cjs.js +70 -0
- package/dist/lib/packager/createDistWorkspace.cjs.js +3 -3
- package/dist/lib/{experimental/startBackendExperimental.cjs.js → runner/runBackend.cjs.js} +6 -5
- package/dist/lib/version.cjs.js +30 -22
- package/dist/packages/backend-defaults/package.json.cjs.js +1 -1
- package/dist/packages/backend-plugin-api/package.json.cjs.js +1 -1
- package/dist/packages/backend-test-utils/package.json.cjs.js +1 -1
- package/dist/packages/catalog-client/package.json.cjs.js +6 -0
- package/dist/packages/cli/package.json.cjs.js +15 -5
- package/dist/packages/core-app-api/package.json.cjs.js +1 -1
- package/dist/packages/core-components/package.json.cjs.js +1 -1
- package/dist/packages/core-plugin-api/package.json.cjs.js +1 -1
- package/dist/packages/dev-utils/package.json.cjs.js +1 -1
- package/dist/packages/errors/package.json.cjs.js +6 -0
- package/dist/packages/test-utils/package.json.cjs.js +1 -1
- package/dist/packages/theme/package.json.cjs.js +1 -1
- package/dist/plugins/auth-backend/package.json.cjs.js +1 -1
- package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +1 -1
- package/dist/plugins/catalog-node/package.json.cjs.js +6 -0
- package/dist/plugins/scaffolder-node/package.json.cjs.js +1 -1
- package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +6 -0
- package/package.json +45 -19
- package/templates/default-backend-plugin/README.md.hbs +22 -8
- package/templates/default-backend-plugin/dev/index.ts.hbs +60 -0
- package/templates/default-backend-plugin/package.json.hbs +5 -5
- package/templates/default-backend-plugin/src/index.ts.hbs +0 -1
- package/templates/default-backend-plugin/src/plugin.test.ts.hbs +85 -0
- package/templates/default-backend-plugin/src/plugin.ts.hbs +16 -14
- package/templates/default-backend-plugin/src/router.test.ts +67 -0
- package/templates/default-backend-plugin/src/router.ts +51 -0
- package/templates/default-backend-plugin/src/services/TodoListService/createTodoListService.ts +100 -0
- package/templates/default-backend-plugin/src/services/TodoListService/index.ts +1 -0
- package/templates/default-backend-plugin/src/services/TodoListService/types.ts +27 -0
- package/templates/scaffolder-module/package.json.hbs +3 -1
- package/templates/scaffolder-module/src/actions/example.test.ts +24 -0
- package/templates/scaffolder-module/src/actions/{example/example.ts → example.ts} +7 -3
- package/templates/scaffolder-module/src/index.ts.hbs +1 -1
- package/templates/scaffolder-module/src/{actions/example/module.ts → module.ts} +3 -3
- package/dist/lib/bundler/LinkedPackageResolvePlugin.cjs.js +0 -47
- package/dist/lib/bundler/backend.cjs.js +0 -36
- package/templates/default-backend-plugin/dev/index.ts +0 -9
- package/templates/default-backend-plugin/src/service/router.test.ts +0 -30
- package/templates/default-backend-plugin/src/service/router.ts +0 -28
- package/templates/scaffolder-module/src/actions/example/example.test.ts +0 -32
- package/templates/scaffolder-module/src/actions/example/index.ts +0 -7
- package/templates/scaffolder-module/src/actions/index.ts +0 -1
- /package/dist/lib/{experimental → ipc}/IpcServer.cjs.js +0 -0
- /package/dist/lib/{experimental → ipc}/ServerDataStore.cjs.js +0 -0
|
@@ -2,40 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('path');
|
|
4
4
|
var chalk = require('chalk');
|
|
5
|
-
var webpack = require('webpack');
|
|
5
|
+
var webpack$1 = require('webpack');
|
|
6
6
|
var ESLintPlugin = require('eslint-webpack-plugin');
|
|
7
7
|
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
8
8
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
9
|
-
var webpack
|
|
10
|
-
var LinkedPackageResolvePlugin = require('./LinkedPackageResolvePlugin.cjs.js');
|
|
9
|
+
var webpack = require('@module-federation/enhanced/webpack');
|
|
11
10
|
var ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
|
12
|
-
var runScriptWebpackPlugin = require('run-script-webpack-plugin');
|
|
13
11
|
var ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
14
12
|
var paths = require('../paths.cjs.js');
|
|
15
13
|
var fs = require('fs-extra');
|
|
16
|
-
var getPackages = require('@manypkg/get-packages');
|
|
17
|
-
var cliCommon = require('@backstage/cli-common');
|
|
18
|
-
var nodeExternals = require('webpack-node-externals');
|
|
19
14
|
var optimization = require('./optimization.cjs.js');
|
|
20
15
|
var pickBy = require('lodash/pickBy');
|
|
21
|
-
var entryPoints = require('../entryPoints.cjs.js');
|
|
22
16
|
var run = require('../run.cjs.js');
|
|
23
17
|
var transforms = require('./transforms.cjs.js');
|
|
24
18
|
var version = require('../version.cjs.js');
|
|
25
19
|
var yn = require('yn');
|
|
26
20
|
var hasReactDomClient = require('./hasReactDomClient.cjs.js');
|
|
21
|
+
var linkWorkspaces = require('./linkWorkspaces.cjs.js');
|
|
27
22
|
|
|
28
23
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
29
24
|
|
|
30
25
|
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
31
|
-
var webpack__default = /*#__PURE__*/_interopDefaultCompat(webpack);
|
|
26
|
+
var webpack__default = /*#__PURE__*/_interopDefaultCompat(webpack$1);
|
|
32
27
|
var ESLintPlugin__default = /*#__PURE__*/_interopDefaultCompat(ESLintPlugin);
|
|
33
28
|
var ForkTsCheckerWebpackPlugin__default = /*#__PURE__*/_interopDefaultCompat(ForkTsCheckerWebpackPlugin);
|
|
34
29
|
var HtmlWebpackPlugin__default = /*#__PURE__*/_interopDefaultCompat(HtmlWebpackPlugin);
|
|
35
30
|
var ModuleScopePlugin__default = /*#__PURE__*/_interopDefaultCompat(ModuleScopePlugin);
|
|
36
31
|
var ReactRefreshPlugin__default = /*#__PURE__*/_interopDefaultCompat(ReactRefreshPlugin);
|
|
37
32
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
38
|
-
var nodeExternals__default = /*#__PURE__*/_interopDefaultCompat(nodeExternals);
|
|
39
33
|
var pickBy__default = /*#__PURE__*/_interopDefaultCompat(pickBy);
|
|
40
34
|
var yn__default = /*#__PURE__*/_interopDefaultCompat(yn);
|
|
41
35
|
|
|
@@ -84,17 +78,16 @@ async function readBuildInfo() {
|
|
|
84
78
|
commit: commit ?? "unknown"
|
|
85
79
|
};
|
|
86
80
|
}
|
|
87
|
-
async function createConfig(paths
|
|
81
|
+
async function createConfig(paths, options) {
|
|
88
82
|
const {
|
|
89
83
|
checksEnabled,
|
|
90
84
|
isDev,
|
|
91
85
|
frontendConfig,
|
|
92
86
|
moduleFederation,
|
|
93
|
-
publicSubPath = ""
|
|
87
|
+
publicSubPath = "",
|
|
88
|
+
rspack
|
|
94
89
|
} = options;
|
|
95
90
|
const { plugins, loaders } = transforms.transforms(options);
|
|
96
|
-
const { packages } = await getPackages.getPackages(paths.paths.targetDir);
|
|
97
|
-
const externalPkgs = packages.filter((p) => !cliCommon.isChildPath(paths$1.root, p.dir));
|
|
98
91
|
const validBaseUrl = resolveBaseUrl(frontendConfig, moduleFederation);
|
|
99
92
|
let publicPath = validBaseUrl.pathname.replace(/\/$/, "");
|
|
100
93
|
if (publicSubPath) {
|
|
@@ -105,40 +98,47 @@ async function createConfig(paths$1, options) {
|
|
|
105
98
|
options.frontendConfig,
|
|
106
99
|
options.moduleFederation
|
|
107
100
|
);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
if (rspack) {
|
|
102
|
+
const RspackReactRefreshPlugin = require("@rspack/plugin-react-refresh");
|
|
103
|
+
plugins.push(new RspackReactRefreshPlugin());
|
|
104
|
+
} else {
|
|
105
|
+
plugins.push(
|
|
106
|
+
new ReactRefreshPlugin__default.default({
|
|
107
|
+
overlay: {
|
|
108
|
+
sockProtocol: "ws",
|
|
109
|
+
sockHost: host,
|
|
110
|
+
sockPort: port
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
}
|
|
117
115
|
}
|
|
118
116
|
if (checksEnabled) {
|
|
119
117
|
plugins.push(
|
|
120
118
|
new ForkTsCheckerWebpackPlugin__default.default({
|
|
121
|
-
typescript: { configFile: paths
|
|
119
|
+
typescript: { configFile: paths.targetTsConfig, memoryLimit: 4096 }
|
|
122
120
|
}),
|
|
123
121
|
new ESLintPlugin__default.default({
|
|
124
|
-
context: paths
|
|
122
|
+
context: paths.targetPath,
|
|
125
123
|
files: ["**/*.(ts|tsx|mts|cts|js|jsx|mjs|cjs)"]
|
|
126
124
|
})
|
|
127
125
|
);
|
|
128
126
|
}
|
|
127
|
+
const bundler = rspack ? rspack : webpack__default.default;
|
|
129
128
|
plugins.push(
|
|
130
|
-
new
|
|
129
|
+
new bundler.ProvidePlugin({
|
|
131
130
|
process: require.resolve("process/browser"),
|
|
132
131
|
Buffer: ["buffer", "Buffer"]
|
|
133
132
|
})
|
|
134
133
|
);
|
|
135
134
|
if (options.moduleFederation?.mode !== "remote") {
|
|
136
135
|
plugins.push(
|
|
136
|
+
// `rspack.HtmlRspackPlugin` does not support object type `templateParameters` value, `frontendConfig` in this case
|
|
137
137
|
new HtmlWebpackPlugin__default.default({
|
|
138
138
|
meta: {
|
|
139
139
|
"backstage-app-mode": options?.appMode ?? "public"
|
|
140
140
|
},
|
|
141
|
-
template: paths
|
|
141
|
+
template: paths.targetHtml,
|
|
142
142
|
templateParameters: {
|
|
143
143
|
publicPath,
|
|
144
144
|
config: frontendConfig
|
|
@@ -155,18 +155,19 @@ async function createConfig(paths$1, options) {
|
|
|
155
155
|
minify: false,
|
|
156
156
|
publicPath: "<%= publicPath %>",
|
|
157
157
|
filename: "index.html.tmpl",
|
|
158
|
-
template:
|
|
158
|
+
template: `${require.resolve("raw-loader")}!${paths.targetHtml}`
|
|
159
159
|
})
|
|
160
160
|
);
|
|
161
161
|
}
|
|
162
162
|
if (options.moduleFederation) {
|
|
163
163
|
const isRemote = options.moduleFederation?.mode === "remote";
|
|
164
|
+
const AdaptedModuleFederationPlugin = rspack ? rspack.container.ModuleFederationPlugin : webpack.ModuleFederationPlugin;
|
|
164
165
|
plugins.push(
|
|
165
|
-
new
|
|
166
|
+
new AdaptedModuleFederationPlugin({
|
|
166
167
|
...isRemote && {
|
|
167
168
|
filename: "remoteEntry.js",
|
|
168
169
|
exposes: {
|
|
169
|
-
".": paths
|
|
170
|
+
".": paths.targetEntry
|
|
170
171
|
}
|
|
171
172
|
},
|
|
172
173
|
name: options.moduleFederation.name,
|
|
@@ -222,9 +223,12 @@ async function createConfig(paths$1, options) {
|
|
|
222
223
|
}
|
|
223
224
|
const buildInfo = await readBuildInfo();
|
|
224
225
|
plugins.push(
|
|
225
|
-
new
|
|
226
|
+
new bundler.DefinePlugin({
|
|
226
227
|
"process.env.BUILD_INFO": JSON.stringify(buildInfo),
|
|
227
|
-
"process.env.APP_CONFIG":
|
|
228
|
+
"process.env.APP_CONFIG": rspack ? (
|
|
229
|
+
// FIXME: see also https://github.com/web-infra-dev/rspack/issues/5606
|
|
230
|
+
JSON.stringify(options.getFrontendAppConfigs())
|
|
231
|
+
) : bundler.DefinePlugin.runtimeValue(
|
|
228
232
|
() => JSON.stringify(options.getFrontendAppConfigs()),
|
|
229
233
|
true
|
|
230
234
|
),
|
|
@@ -233,11 +237,21 @@ async function createConfig(paths$1, options) {
|
|
|
233
237
|
"process.env.HAS_REACT_DOM_CLIENT": JSON.stringify(hasReactDomClient.hasReactDomClient())
|
|
234
238
|
})
|
|
235
239
|
);
|
|
236
|
-
|
|
240
|
+
if (options.linkedWorkspace) {
|
|
241
|
+
plugins.push(
|
|
242
|
+
...await linkWorkspaces.createWorkspaceLinkingPlugins(
|
|
243
|
+
bundler,
|
|
244
|
+
options.linkedWorkspace
|
|
245
|
+
)
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
const reactRefreshFiles = rspack ? [] : [
|
|
237
249
|
require.resolve(
|
|
238
250
|
"@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js"
|
|
239
251
|
),
|
|
240
|
-
require.resolve(
|
|
252
|
+
require.resolve(
|
|
253
|
+
"@pmmmwh/react-refresh-webpack-plugin/overlay/index.js"
|
|
254
|
+
),
|
|
241
255
|
require.resolve("react-refresh")
|
|
242
256
|
];
|
|
243
257
|
const mode = isDev ? "development" : "production";
|
|
@@ -254,15 +268,16 @@ async function createConfig(paths$1, options) {
|
|
|
254
268
|
];
|
|
255
269
|
optimization$1.nodeEnv = false;
|
|
256
270
|
plugins.push(
|
|
257
|
-
new
|
|
258
|
-
"process.env.NODE_ENV":
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return
|
|
271
|
+
new bundler.DefinePlugin({
|
|
272
|
+
"process.env.NODE_ENV": rspack ? (
|
|
273
|
+
// FIXME: see also https://github.com/web-infra-dev/rspack/issues/5606
|
|
274
|
+
JSON.stringify(mode)
|
|
275
|
+
) : webpack__default.default.DefinePlugin.runtimeValue(({ module }) => {
|
|
276
|
+
if (reactPackageDirs.some((val) => module.resource.startsWith(val))) {
|
|
277
|
+
return '"development"';
|
|
264
278
|
}
|
|
265
|
-
|
|
279
|
+
return `"${mode}"`;
|
|
280
|
+
})
|
|
266
281
|
})
|
|
267
282
|
);
|
|
268
283
|
}
|
|
@@ -282,11 +297,11 @@ async function createConfig(paths$1, options) {
|
|
|
282
297
|
// we check the gzip size instead
|
|
283
298
|
},
|
|
284
299
|
devtool: isDev ? "eval-cheap-module-source-map" : "source-map",
|
|
285
|
-
context: paths
|
|
300
|
+
context: paths.targetPath,
|
|
286
301
|
entry: [
|
|
287
302
|
require.resolve("@backstage/cli/config/webpack-public-path"),
|
|
288
303
|
...options.additionalEntryPoints ?? [],
|
|
289
|
-
paths
|
|
304
|
+
paths.targetEntry
|
|
290
305
|
],
|
|
291
306
|
resolve: {
|
|
292
307
|
extensions: [".ts", ".tsx", ".mjs", ".js", ".jsx", ".json", ".wasm"],
|
|
@@ -307,20 +322,22 @@ async function createConfig(paths$1, options) {
|
|
|
307
322
|
http: false,
|
|
308
323
|
util: require.resolve("util/")
|
|
309
324
|
},
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
325
|
+
// FIXME: see also https://github.com/web-infra-dev/rspack/issues/3408
|
|
326
|
+
...!rspack && {
|
|
327
|
+
plugins: [
|
|
328
|
+
new ModuleScopePlugin__default.default(
|
|
329
|
+
[paths.targetSrc, paths.targetDev],
|
|
330
|
+
[paths.targetPackageJson, ...reactRefreshFiles]
|
|
331
|
+
)
|
|
332
|
+
]
|
|
333
|
+
}
|
|
317
334
|
},
|
|
318
335
|
module: {
|
|
319
336
|
rules: loaders
|
|
320
337
|
},
|
|
321
338
|
output: {
|
|
322
339
|
uniqueName: options.moduleFederation?.name,
|
|
323
|
-
path: paths
|
|
340
|
+
path: paths.targetDist,
|
|
324
341
|
publicPath: options.moduleFederation?.mode === "remote" ? "auto" : `${publicPath}/`,
|
|
325
342
|
filename: isDev ? "[name].js" : "static/[name].[fullhash:8].js",
|
|
326
343
|
chunkFilename: isDev ? "[name].chunk.js" : "static/[name].[chunkhash:8].chunk.js",
|
|
@@ -332,137 +349,24 @@ async function createConfig(paths$1, options) {
|
|
|
332
349
|
} : {}
|
|
333
350
|
},
|
|
334
351
|
experiments: {
|
|
335
|
-
lazyCompilation: yn__default.default(process.env.EXPERIMENTAL_LAZY_COMPILATION)
|
|
352
|
+
lazyCompilation: !rspack && yn__default.default(process.env.EXPERIMENTAL_LAZY_COMPILATION),
|
|
353
|
+
...rspack && {
|
|
354
|
+
// We're still using `style-loader` for custom `insert` option
|
|
355
|
+
css: false
|
|
356
|
+
}
|
|
336
357
|
},
|
|
337
358
|
plugins,
|
|
338
|
-
...withCache
|
|
359
|
+
...withCache && {
|
|
339
360
|
cache: {
|
|
340
361
|
type: "filesystem",
|
|
341
362
|
buildDependencies: {
|
|
342
363
|
config: [__filename]
|
|
343
364
|
}
|
|
344
365
|
}
|
|
345
|
-
} : {}
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
async function createBackendConfig(paths$1, options) {
|
|
349
|
-
const { checksEnabled, isDev } = options;
|
|
350
|
-
const { packages } = await getPackages.getPackages(paths.paths.targetDir);
|
|
351
|
-
const localPackageEntryPoints = packages.flatMap((p) => {
|
|
352
|
-
const entryPoints$1 = entryPoints.readEntryPoints(p.packageJson);
|
|
353
|
-
return entryPoints$1.map((e) => path.posix.join(p.packageJson.name, e.mount));
|
|
354
|
-
});
|
|
355
|
-
const moduleDirs = packages.map((p) => path.resolve(p.dir, "node_modules"));
|
|
356
|
-
const externalPkgs = packages.filter((p) => !cliCommon.isChildPath(paths$1.root, p.dir));
|
|
357
|
-
const { loaders } = transforms.transforms({ ...options, isBackend: true });
|
|
358
|
-
const runScriptNodeArgs = new Array();
|
|
359
|
-
if (options.inspectEnabled) {
|
|
360
|
-
const inspect = typeof options.inspectEnabled === "string" ? `--inspect=${options.inspectEnabled}` : "--inspect";
|
|
361
|
-
runScriptNodeArgs.push(inspect);
|
|
362
|
-
} else if (options.inspectBrkEnabled) {
|
|
363
|
-
const inspect = typeof options.inspectBrkEnabled === "string" ? `--inspect-brk=${options.inspectBrkEnabled}` : "--inspect-brk";
|
|
364
|
-
runScriptNodeArgs.push(inspect);
|
|
365
|
-
}
|
|
366
|
-
if (options.require) {
|
|
367
|
-
runScriptNodeArgs.push(`--require=${options.require}`);
|
|
368
|
-
}
|
|
369
|
-
return {
|
|
370
|
-
mode: isDev ? "development" : "production",
|
|
371
|
-
profile: false,
|
|
372
|
-
...isDev ? {
|
|
373
|
-
watch: true,
|
|
374
|
-
watchOptions: {
|
|
375
|
-
ignored: /node_modules\/(?!\@backstage)/
|
|
376
|
-
}
|
|
377
|
-
} : {},
|
|
378
|
-
externals: [
|
|
379
|
-
nodeExternalsWithResolve({
|
|
380
|
-
modulesDir: paths$1.rootNodeModules,
|
|
381
|
-
additionalModuleDirs: moduleDirs,
|
|
382
|
-
allowlist: ["webpack/hot/poll?100", ...localPackageEntryPoints]
|
|
383
|
-
})
|
|
384
|
-
],
|
|
385
|
-
target: "node",
|
|
386
|
-
node: {
|
|
387
|
-
/* eslint-disable-next-line no-restricted-syntax */
|
|
388
|
-
__dirname: true,
|
|
389
|
-
__filename: true,
|
|
390
|
-
global: true
|
|
391
|
-
},
|
|
392
|
-
bail: false,
|
|
393
|
-
performance: {
|
|
394
|
-
hints: false
|
|
395
|
-
// we check the gzip size instead
|
|
396
|
-
},
|
|
397
|
-
devtool: isDev ? "eval-cheap-module-source-map" : "source-map",
|
|
398
|
-
context: paths$1.targetPath,
|
|
399
|
-
entry: [
|
|
400
|
-
"webpack/hot/poll?100",
|
|
401
|
-
paths$1.targetRunFile ? paths$1.targetRunFile : paths$1.targetEntry
|
|
402
|
-
],
|
|
403
|
-
resolve: {
|
|
404
|
-
extensions: [".ts", ".mjs", ".js", ".json"],
|
|
405
|
-
mainFields: ["main"],
|
|
406
|
-
modules: [paths$1.rootNodeModules, ...moduleDirs],
|
|
407
|
-
plugins: [
|
|
408
|
-
new LinkedPackageResolvePlugin.LinkedPackageResolvePlugin(paths$1.rootNodeModules, externalPkgs),
|
|
409
|
-
new ModuleScopePlugin__default.default(
|
|
410
|
-
[paths$1.targetSrc, paths$1.targetDev],
|
|
411
|
-
[paths$1.targetPackageJson]
|
|
412
|
-
)
|
|
413
|
-
]
|
|
414
|
-
},
|
|
415
|
-
module: {
|
|
416
|
-
rules: loaders
|
|
417
|
-
},
|
|
418
|
-
output: {
|
|
419
|
-
path: paths$1.targetDist,
|
|
420
|
-
filename: isDev ? "[name].js" : "[name].[hash:8].js",
|
|
421
|
-
chunkFilename: isDev ? "[name].chunk.js" : "[name].[chunkhash:8].chunk.js",
|
|
422
|
-
...isDev ? {
|
|
423
|
-
devtoolModuleFilenameTemplate: (info) => `file:///${path.resolve(info.absoluteResourcePath).replace(
|
|
424
|
-
/\\/g,
|
|
425
|
-
"/"
|
|
426
|
-
)}`
|
|
427
|
-
} : {}
|
|
428
|
-
},
|
|
429
|
-
plugins: [
|
|
430
|
-
new runScriptWebpackPlugin.RunScriptWebpackPlugin({
|
|
431
|
-
name: "main.js",
|
|
432
|
-
nodeArgs: runScriptNodeArgs.length > 0 ? runScriptNodeArgs : void 0,
|
|
433
|
-
args: process.argv.slice(3)
|
|
434
|
-
// drop `node backstage-cli backend:dev`
|
|
435
|
-
}),
|
|
436
|
-
new webpack__default.default.HotModuleReplacementPlugin(),
|
|
437
|
-
...checksEnabled ? [
|
|
438
|
-
new ForkTsCheckerWebpackPlugin__default.default({
|
|
439
|
-
typescript: { configFile: paths$1.targetTsConfig }
|
|
440
|
-
}),
|
|
441
|
-
new ESLintPlugin__default.default({
|
|
442
|
-
files: ["**/*.(ts|tsx|mts|cts|js|jsx|mjs|cjs)"]
|
|
443
|
-
})
|
|
444
|
-
] : []
|
|
445
|
-
]
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
function nodeExternalsWithResolve(options) {
|
|
449
|
-
let currentContext;
|
|
450
|
-
const externals = nodeExternals__default.default({
|
|
451
|
-
...options,
|
|
452
|
-
importType(request) {
|
|
453
|
-
const resolved = require.resolve(request, {
|
|
454
|
-
paths: [currentContext]
|
|
455
|
-
});
|
|
456
|
-
return `commonjs ${resolved}`;
|
|
457
366
|
}
|
|
458
|
-
});
|
|
459
|
-
return ({ context, request }, callback) => {
|
|
460
|
-
currentContext = context;
|
|
461
|
-
return externals(context, request, callback);
|
|
462
367
|
};
|
|
463
368
|
}
|
|
464
369
|
|
|
465
|
-
exports.createBackendConfig = createBackendConfig;
|
|
466
370
|
exports.createConfig = createConfig;
|
|
467
371
|
exports.resolveBaseUrl = resolveBaseUrl;
|
|
468
372
|
exports.resolveEndpoint = resolveEndpoint;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var paths = require('../paths.cjs.js');
|
|
4
|
+
|
|
3
5
|
function hasReactDomClient() {
|
|
4
6
|
try {
|
|
5
|
-
require.resolve("react-dom/client"
|
|
7
|
+
require.resolve("react-dom/client", {
|
|
8
|
+
paths: [paths.paths.targetDir]
|
|
9
|
+
});
|
|
6
10
|
return true;
|
|
7
11
|
} catch {
|
|
8
12
|
return false;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var getPackages = require('@manypkg/get-packages');
|
|
5
|
+
var paths = require('../paths.cjs.js');
|
|
6
|
+
|
|
7
|
+
async function createWorkspaceLinkingPlugins(bundler, workspace) {
|
|
8
|
+
const { packages: linkedPackages, root: linkedRoot } = await getPackages.getPackages(
|
|
9
|
+
workspace
|
|
10
|
+
);
|
|
11
|
+
const replacementRegex = new RegExp(
|
|
12
|
+
`^(?:${linkedPackages.map((pkg) => pkg.packageJson.name).join("|")})(?:/.*)?$`
|
|
13
|
+
);
|
|
14
|
+
return [
|
|
15
|
+
// Any imports of a package that is present in the linked workspace will
|
|
16
|
+
// be redirected to be resolved within the context of the linked workspace
|
|
17
|
+
new bundler.NormalModuleReplacementPlugin(replacementRegex, (resource) => {
|
|
18
|
+
resource.context = linkedRoot.dir;
|
|
19
|
+
}),
|
|
20
|
+
// react and react-dom are always resolved from the target directory
|
|
21
|
+
// Note: this often requires that the linked and target workspace use the same versions of React
|
|
22
|
+
new bundler.NormalModuleReplacementPlugin(/^react(?:-dom)?$/, (resource) => {
|
|
23
|
+
if (!path.relative(linkedRoot.dir, resource.context).startsWith("..")) {
|
|
24
|
+
resource.context = paths.paths.targetDir;
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.createWorkspaceLinkingPlugins = createWorkspaceLinkingPlugins;
|
|
31
|
+
//# sourceMappingURL=linkWorkspaces.cjs.js.map
|
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
const { EsbuildPlugin } = require("esbuild-loader");
|
|
4
4
|
const optimization = (options) => {
|
|
5
|
-
const { isDev } = options;
|
|
5
|
+
const { isDev, rspack } = options;
|
|
6
|
+
const MinifyPlugin = rspack ? rspack.SwcJsMinimizerRspackPlugin : EsbuildPlugin;
|
|
6
7
|
return {
|
|
7
8
|
minimize: !isDev,
|
|
8
9
|
minimizer: [
|
|
9
|
-
new
|
|
10
|
+
new MinifyPlugin({
|
|
10
11
|
target: "ES2022",
|
|
11
12
|
format: "iife",
|
|
12
13
|
exclude: "remoteEntry.js"
|
|
13
14
|
}),
|
|
14
15
|
// Avoid iife wrapping of module federation remote entry as it breaks the variable assignment
|
|
15
|
-
new
|
|
16
|
+
new MinifyPlugin({
|
|
16
17
|
target: "ES2022",
|
|
17
18
|
format: void 0,
|
|
18
19
|
include: "remoteEntry.js"
|
|
19
|
-
})
|
|
20
|
+
}),
|
|
21
|
+
rspack && new rspack.LightningCssMinimizerRspackPlugin()
|
|
20
22
|
],
|
|
21
23
|
runtimeChunk: "single",
|
|
22
24
|
splitChunks: {
|
|
@@ -42,8 +44,10 @@ const optimization = (options) => {
|
|
|
42
44
|
priority: 10,
|
|
43
45
|
minSize: 1e5,
|
|
44
46
|
minChunks: 1,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
...!rspack && {
|
|
48
|
+
maxAsyncRequests: Infinity,
|
|
49
|
+
maxInitialRequests: Infinity
|
|
50
|
+
}
|
|
47
51
|
},
|
|
48
52
|
// filename is not included in type, but we need it
|
|
49
53
|
// Group together the smallest modules
|
|
@@ -81,12 +81,14 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
81
81
|
viteServer?.restart();
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
+
const rspack = process.env.EXPERIMENTAL_RSPACK ? require("@rspack/core") : void 0;
|
|
84
85
|
const commonConfigOptions = {
|
|
85
86
|
...options,
|
|
86
87
|
checksEnabled: options.checksEnabled,
|
|
87
88
|
isDev: true,
|
|
88
89
|
baseUrl: url,
|
|
89
90
|
frontendConfig,
|
|
91
|
+
rspack,
|
|
90
92
|
getFrontendAppConfigs: () => {
|
|
91
93
|
return latestFrontendAppConfigs;
|
|
92
94
|
}
|
|
@@ -99,22 +101,58 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
99
101
|
if (process.env.EXPERIMENTAL_VITE) {
|
|
100
102
|
const vite = require("vite");
|
|
101
103
|
const { default: viteReact } = require("@vitejs/plugin-react");
|
|
102
|
-
const {
|
|
103
|
-
|
|
104
|
-
} = require("vite-plugin-node-polyfills");
|
|
104
|
+
const { default: viteYaml } = require("@modyfi/vite-plugin-yaml");
|
|
105
|
+
const { nodePolyfills: viteNodePolyfills } = require("vite-plugin-node-polyfills");
|
|
105
106
|
const { createHtmlPlugin: viteHtml } = require("vite-plugin-html");
|
|
106
107
|
viteServer = await vite.createServer({
|
|
107
108
|
define: {
|
|
108
|
-
global: "window",
|
|
109
109
|
"process.argv": JSON.stringify(process.argv),
|
|
110
110
|
"process.env.APP_CONFIG": JSON.stringify(cliConfig.frontendAppConfigs),
|
|
111
111
|
// This allows for conditional imports of react-dom/client, since there's no way
|
|
112
112
|
// to check for presence of it in source code without module resolution errors.
|
|
113
113
|
"process.env.HAS_REACT_DOM_CLIENT": JSON.stringify(hasReactDomClient.hasReactDomClient())
|
|
114
114
|
},
|
|
115
|
+
optimizeDeps: {
|
|
116
|
+
esbuildOptions: {
|
|
117
|
+
plugins: [
|
|
118
|
+
{
|
|
119
|
+
name: "custom-define",
|
|
120
|
+
setup(build) {
|
|
121
|
+
const define = build.initialOptions.define ||= {};
|
|
122
|
+
define["process.env.HAS_REACT_DOM_CLIENT"] = JSON.stringify(
|
|
123
|
+
hasReactDomClient.hasReactDomClient()
|
|
124
|
+
);
|
|
125
|
+
define["process.env.NODE_ENV"] = JSON.stringify("development");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
},
|
|
115
131
|
plugins: [
|
|
116
132
|
viteReact(),
|
|
117
|
-
viteNodePolyfills(
|
|
133
|
+
viteNodePolyfills({
|
|
134
|
+
include: [
|
|
135
|
+
"buffer",
|
|
136
|
+
"events",
|
|
137
|
+
"fs",
|
|
138
|
+
"http",
|
|
139
|
+
"https",
|
|
140
|
+
"os",
|
|
141
|
+
"path",
|
|
142
|
+
"process",
|
|
143
|
+
"querystring",
|
|
144
|
+
"stream",
|
|
145
|
+
"url",
|
|
146
|
+
"util",
|
|
147
|
+
"zlib"
|
|
148
|
+
],
|
|
149
|
+
globals: {
|
|
150
|
+
global: true,
|
|
151
|
+
Buffer: true,
|
|
152
|
+
process: true
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
viteYaml(),
|
|
118
156
|
viteHtml({
|
|
119
157
|
entry: paths$2.targetEntry,
|
|
120
158
|
// todo(blam): we should look at contributing to thPe plugin here
|
|
@@ -136,6 +174,8 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
136
174
|
root: paths$2.targetPath
|
|
137
175
|
});
|
|
138
176
|
} else {
|
|
177
|
+
const bundler = rspack ?? webpack__default.default;
|
|
178
|
+
const DevServer = rspack ? require("@rspack/dev-server").RspackDevServer : WebpackDevServer__default.default;
|
|
139
179
|
const publicPaths = await paths.resolveOptionalBundlingPaths({
|
|
140
180
|
entry: "src/index-public-experimental",
|
|
141
181
|
dist: "dist/public"
|
|
@@ -147,8 +187,8 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
147
187
|
)
|
|
148
188
|
);
|
|
149
189
|
}
|
|
150
|
-
const compiler = publicPaths ?
|
|
151
|
-
webpackServer = new
|
|
190
|
+
const compiler = publicPaths ? bundler([config$2, await config$1.createConfig(publicPaths, commonConfigOptions)]) : bundler(config$2);
|
|
191
|
+
webpackServer = new DevServer(
|
|
152
192
|
{
|
|
153
193
|
hot: !process.env.CI,
|
|
154
194
|
devMiddleware: {
|
|
@@ -8,7 +8,8 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
var MiniCssExtractPlugin__default = /*#__PURE__*/_interopDefaultCompat(MiniCssExtractPlugin);
|
|
9
9
|
|
|
10
10
|
const transforms = (options) => {
|
|
11
|
-
const { isDev, isBackend } = options;
|
|
11
|
+
const { isDev, isBackend, rspack } = options;
|
|
12
|
+
const CssExtractRspackPlugin = rspack ? rspack.CssExtractRspackPlugin : MiniCssExtractPlugin__default.default;
|
|
12
13
|
function insertBeforeJssStyles(element) {
|
|
13
14
|
const head = document.head;
|
|
14
15
|
const firstJssNode = head.querySelector("style[data-jss]");
|
|
@@ -24,7 +25,7 @@ const transforms = (options) => {
|
|
|
24
25
|
exclude: /node_modules/,
|
|
25
26
|
use: [
|
|
26
27
|
{
|
|
27
|
-
loader: require.resolve("swc-loader"),
|
|
28
|
+
loader: rspack ? "builtin:swc-loader" : require.resolve("swc-loader"),
|
|
28
29
|
options: {
|
|
29
30
|
jsc: {
|
|
30
31
|
target: "es2022",
|
|
@@ -50,7 +51,7 @@ const transforms = (options) => {
|
|
|
50
51
|
exclude: /node_modules/,
|
|
51
52
|
use: [
|
|
52
53
|
{
|
|
53
|
-
loader: require.resolve("swc-loader"),
|
|
54
|
+
loader: rspack ? "builtin:swc-loader" : require.resolve("swc-loader"),
|
|
54
55
|
options: {
|
|
55
56
|
jsc: {
|
|
56
57
|
target: "es2022",
|
|
@@ -81,7 +82,7 @@ const transforms = (options) => {
|
|
|
81
82
|
test: [/\.icon\.svg$/],
|
|
82
83
|
use: [
|
|
83
84
|
{
|
|
84
|
-
loader: require.resolve("swc-loader"),
|
|
85
|
+
loader: rspack ? "builtin:swc-loader" : require.resolve("swc-loader"),
|
|
85
86
|
options: {
|
|
86
87
|
jsc: {
|
|
87
88
|
target: "es2022",
|
|
@@ -143,7 +144,7 @@ const transforms = (options) => {
|
|
|
143
144
|
options: {
|
|
144
145
|
insert: insertBeforeJssStyles
|
|
145
146
|
}
|
|
146
|
-
} :
|
|
147
|
+
} : CssExtractRspackPlugin.loader,
|
|
147
148
|
{
|
|
148
149
|
loader: require.resolve("css-loader"),
|
|
149
150
|
options: {
|
|
@@ -156,7 +157,7 @@ const transforms = (options) => {
|
|
|
156
157
|
const plugins = new Array();
|
|
157
158
|
if (!isDev) {
|
|
158
159
|
plugins.push(
|
|
159
|
-
new
|
|
160
|
+
new CssExtractRspackPlugin({
|
|
160
161
|
filename: "static/[name].[contenthash:8].css",
|
|
161
162
|
chunkFilename: "static/[name].[id].[contenthash:8].css",
|
|
162
163
|
insert: insertBeforeJssStyles
|