@backstage/cli 0.35.4-next.2 → 0.35.5-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 +55 -0
- package/dist/index.cjs.js +1 -0
- package/dist/lib/cache/SuccessCache.cjs.js +2 -2
- package/dist/lib/typeDistProject.cjs.js +2 -2
- package/dist/lib/version.cjs.js +4 -3
- package/dist/lib/yarnPlugin.cjs.js +2 -2
- package/dist/modules/build/commands/package/build/command.cjs.js +16 -8
- package/dist/modules/build/commands/package/start/command.cjs.js +3 -3
- package/dist/modules/build/commands/package/start/startBackend.cjs.js +2 -2
- package/dist/modules/build/commands/package/start/startFrontend.cjs.js +5 -7
- package/dist/modules/build/commands/repo/build.cjs.js +6 -7
- package/dist/modules/build/commands/repo/start.cjs.js +3 -3
- package/dist/modules/build/index.cjs.js +6 -0
- package/dist/modules/build/lib/buildBackend.cjs.js +0 -2
- package/dist/modules/build/lib/buildFrontend.cjs.js +4 -8
- package/dist/modules/build/lib/builder/config.cjs.js +5 -5
- package/dist/modules/build/lib/builder/packager.cjs.js +7 -8
- package/dist/modules/build/lib/bundler/bundle.cjs.js +9 -2
- package/dist/modules/build/lib/bundler/config.cjs.js +20 -78
- package/dist/modules/build/lib/bundler/hasReactDomClient.cjs.js +2 -2
- package/dist/modules/build/lib/bundler/linkWorkspaces.cjs.js +2 -2
- package/dist/modules/build/lib/bundler/moduleFederation.cjs.js +99 -16
- package/dist/modules/build/lib/bundler/packageDetection.cjs.js +2 -2
- package/dist/modules/build/lib/bundler/paths.cjs.js +8 -6
- package/dist/modules/build/lib/bundler/server.cjs.js +24 -14
- package/dist/modules/build/lib/packager/createDistWorkspace.cjs.js +9 -9
- package/dist/modules/build/lib/packager/productionPack.cjs.js +1 -1
- package/dist/{lib → modules/build/lib}/role.cjs.js +2 -2
- package/dist/modules/build/lib/runner/runBackend.cjs.js +2 -2
- package/dist/modules/config/lib/config.cjs.js +4 -4
- package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +2 -2
- package/dist/modules/info/commands/info.cjs.js +4 -5
- package/dist/modules/lint/commands/package/lint.cjs.js +4 -4
- package/dist/modules/lint/commands/repo/lint.cjs.js +8 -9
- package/dist/modules/maintenance/commands/package/clean.cjs.js +4 -4
- package/dist/modules/maintenance/commands/package/pack.cjs.js +5 -5
- package/dist/modules/maintenance/commands/repo/clean.cjs.js +3 -4
- package/dist/modules/maintenance/commands/repo/fix.cjs.js +7 -7
- package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +4 -4
- package/dist/modules/migrate/commands/packageRole.cjs.js +2 -2
- package/dist/modules/migrate/commands/versions/bump.cjs.js +8 -9
- package/dist/modules/new/lib/codeowners/codeowners.cjs.js +2 -2
- package/dist/modules/new/lib/execution/PortableTemplater.cjs.js +2 -3
- package/dist/modules/new/lib/execution/installNewPackage.cjs.js +4 -4
- package/dist/modules/new/lib/execution/writeTemplateContents.cjs.js +1 -2
- package/dist/modules/new/lib/preparation/collectPortableTemplateInput.cjs.js +2 -2
- package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +2 -2
- package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +2 -2
- package/dist/modules/test/commands/package/test.cjs.js +1 -2
- package/dist/modules/test/commands/repo/test.cjs.js +3 -4
- package/dist/modules/test/index.cjs.js +3 -1
- package/dist/modules/translations/commands/export.cjs.js +104 -0
- package/dist/modules/translations/commands/import.cjs.js +141 -0
- package/dist/modules/translations/index.cjs.js +59 -0
- package/dist/modules/translations/lib/discoverPackages.cjs.js +121 -0
- package/dist/modules/translations/lib/extractTranslations.cjs.js +71 -0
- package/dist/modules/translations/lib/messageFilePath.cjs.js +43 -0
- 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 +1 -1
- package/dist/packages/cli/package.json.cjs.js +7 -6
- 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/frontend-defaults/package.json.cjs.js +1 -1
- package/dist/packages/frontend-plugin-api/package.json.cjs.js +1 -1
- package/dist/packages/frontend-test-utils/package.json.cjs.js +1 -1
- 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 +1 -1
- package/dist/plugins/scaffolder-node/package.json.cjs.js +1 -1
- package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +1 -1
- package/package.json +28 -27
- package/dist/lib/parallel.cjs.js +0 -141
- package/dist/lib/paths.cjs.js +0 -8
- /package/dist/{lib → modules/build/lib}/entryPoints.cjs.js +0 -0
|
@@ -7,7 +7,6 @@ var tsCheckerRspackPlugin = require('ts-checker-rspack-plugin');
|
|
|
7
7
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
8
8
|
var ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
|
9
9
|
var rspack = require('@module-federation/enhanced/rspack');
|
|
10
|
-
var paths = require('../../../../lib/paths.cjs.js');
|
|
11
10
|
var fs = require('fs-extra');
|
|
12
11
|
var optimization = require('./optimization.cjs.js');
|
|
13
12
|
var pickBy = require('lodash/pickBy');
|
|
@@ -28,17 +27,17 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
|
28
27
|
var pickBy__default = /*#__PURE__*/_interopDefaultCompat(pickBy);
|
|
29
28
|
var yn__default = /*#__PURE__*/_interopDefaultCompat(yn);
|
|
30
29
|
|
|
31
|
-
function resolveBaseUrl(config,
|
|
30
|
+
function resolveBaseUrl(config, moduleFederationRemote) {
|
|
32
31
|
const baseUrl = config.getOptionalString("app.baseUrl");
|
|
33
|
-
const defaultBaseUrl =
|
|
32
|
+
const defaultBaseUrl = moduleFederationRemote ? `http://localhost:${process.env.PORT ?? "3000"}` : "http://localhost:3000";
|
|
34
33
|
try {
|
|
35
34
|
return new URL(baseUrl ?? "/", defaultBaseUrl);
|
|
36
35
|
} catch (error) {
|
|
37
36
|
throw new Error(`Invalid app.baseUrl, ${error}`);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
function resolveEndpoint(config,
|
|
41
|
-
const url = resolveBaseUrl(config,
|
|
39
|
+
function resolveEndpoint(config, moduleFederationRemote) {
|
|
40
|
+
const url = resolveBaseUrl(config, moduleFederationRemote);
|
|
42
41
|
return {
|
|
43
42
|
host: config.getOptionalString("app.listen.host") ?? url.hostname,
|
|
44
43
|
port: config.getOptionalNumber("app.listen.port") ?? Number(url.port) ?? (url.protocol === "https:" ? 443 : 80)
|
|
@@ -62,7 +61,7 @@ async function readBuildInfo() {
|
|
|
62
61
|
);
|
|
63
62
|
}
|
|
64
63
|
const { version: packageVersion } = await fs__default.default.readJson(
|
|
65
|
-
|
|
64
|
+
cliCommon.targetPaths.resolve("package.json")
|
|
66
65
|
);
|
|
67
66
|
return {
|
|
68
67
|
cliVersion: version.version,
|
|
@@ -77,12 +76,12 @@ async function createConfig(paths, options) {
|
|
|
77
76
|
checksEnabled,
|
|
78
77
|
isDev,
|
|
79
78
|
frontendConfig,
|
|
80
|
-
|
|
79
|
+
moduleFederationRemote,
|
|
81
80
|
publicSubPath = "",
|
|
82
81
|
webpack
|
|
83
82
|
} = options;
|
|
84
83
|
const { plugins, loaders } = transforms.transforms(options);
|
|
85
|
-
const validBaseUrl = resolveBaseUrl(frontendConfig,
|
|
84
|
+
const validBaseUrl = resolveBaseUrl(frontendConfig, moduleFederationRemote);
|
|
86
85
|
let publicPath = validBaseUrl.pathname.replace(/\/$/, "");
|
|
87
86
|
if (publicSubPath) {
|
|
88
87
|
publicPath = `${publicPath}${publicSubPath}`.replace("//", "/");
|
|
@@ -90,7 +89,7 @@ async function createConfig(paths, options) {
|
|
|
90
89
|
if (isDev) {
|
|
91
90
|
const { host, port } = resolveEndpoint(
|
|
92
91
|
options.frontendConfig,
|
|
93
|
-
options.
|
|
92
|
+
options.moduleFederationRemote
|
|
94
93
|
);
|
|
95
94
|
const refreshOptions = {
|
|
96
95
|
overlay: {
|
|
@@ -129,7 +128,7 @@ async function createConfig(paths, options) {
|
|
|
129
128
|
Buffer: ["buffer", "Buffer"]
|
|
130
129
|
})
|
|
131
130
|
);
|
|
132
|
-
if (options.
|
|
131
|
+
if (!options.moduleFederationRemote) {
|
|
133
132
|
const templateOptions = {
|
|
134
133
|
meta: {
|
|
135
134
|
"backstage-app-mode": options?.appMode ?? "public"
|
|
@@ -164,79 +163,22 @@ async function createConfig(paths, options) {
|
|
|
164
163
|
})
|
|
165
164
|
);
|
|
166
165
|
}
|
|
167
|
-
if (options.
|
|
168
|
-
const isRemote = options.moduleFederation?.mode === "remote";
|
|
166
|
+
if (options.moduleFederationRemote) {
|
|
169
167
|
const AdaptedModuleFederationPlugin = webpack ? require("@module-federation/enhanced/webpack").ModuleFederationPlugin : rspack.ModuleFederationPlugin;
|
|
170
|
-
const exposes = options.
|
|
171
|
-
Object.entries(options.
|
|
172
|
-
k,
|
|
173
|
-
|
|
174
|
-
])
|
|
168
|
+
const exposes = options.moduleFederationRemote.exposes ? Object.fromEntries(
|
|
169
|
+
Object.entries(options.moduleFederationRemote?.exposes).map(
|
|
170
|
+
([k, v]) => [k, path.resolve(paths.targetPath, v)]
|
|
171
|
+
)
|
|
175
172
|
) : {
|
|
176
173
|
".": paths.targetEntry
|
|
177
174
|
};
|
|
178
175
|
plugins.push(
|
|
179
176
|
new AdaptedModuleFederationPlugin({
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
},
|
|
184
|
-
name: options.moduleFederation.name,
|
|
177
|
+
filename: "remoteEntry.js",
|
|
178
|
+
exposes,
|
|
179
|
+
name: options.moduleFederationRemote.name,
|
|
185
180
|
runtime: false,
|
|
186
|
-
shared:
|
|
187
|
-
// React
|
|
188
|
-
react: {
|
|
189
|
-
singleton: true,
|
|
190
|
-
requiredVersion: "*",
|
|
191
|
-
eager: !isRemote,
|
|
192
|
-
...isRemote && { import: false }
|
|
193
|
-
},
|
|
194
|
-
"react-dom": {
|
|
195
|
-
singleton: true,
|
|
196
|
-
requiredVersion: "*",
|
|
197
|
-
eager: !isRemote,
|
|
198
|
-
...isRemote && { import: false }
|
|
199
|
-
},
|
|
200
|
-
// React Router
|
|
201
|
-
"react-router": {
|
|
202
|
-
singleton: true,
|
|
203
|
-
requiredVersion: "*",
|
|
204
|
-
eager: !isRemote,
|
|
205
|
-
...isRemote && { import: false }
|
|
206
|
-
},
|
|
207
|
-
"react-router-dom": {
|
|
208
|
-
singleton: true,
|
|
209
|
-
requiredVersion: "*",
|
|
210
|
-
eager: !isRemote,
|
|
211
|
-
...isRemote && { import: false }
|
|
212
|
-
},
|
|
213
|
-
// MUI v4
|
|
214
|
-
// not setting import: false for MUI packages as this
|
|
215
|
-
// will break once Backstage moves to BUI
|
|
216
|
-
"@material-ui/core/styles": {
|
|
217
|
-
singleton: true,
|
|
218
|
-
requiredVersion: "*",
|
|
219
|
-
eager: !isRemote
|
|
220
|
-
},
|
|
221
|
-
"@material-ui/styles": {
|
|
222
|
-
singleton: true,
|
|
223
|
-
requiredVersion: "*",
|
|
224
|
-
eager: !isRemote
|
|
225
|
-
},
|
|
226
|
-
// MUI v5
|
|
227
|
-
// not setting import: false for MUI packages as this
|
|
228
|
-
// will break once Backstage moves to BUI
|
|
229
|
-
"@mui/material/styles/": {
|
|
230
|
-
singleton: true,
|
|
231
|
-
requiredVersion: "*",
|
|
232
|
-
eager: !isRemote
|
|
233
|
-
},
|
|
234
|
-
"@emotion/react": {
|
|
235
|
-
singleton: true,
|
|
236
|
-
requiredVersion: "*",
|
|
237
|
-
eager: !isRemote
|
|
238
|
-
}
|
|
239
|
-
}
|
|
181
|
+
shared: options.moduleFederationRemote.sharedDependencies
|
|
240
182
|
})
|
|
241
183
|
);
|
|
242
184
|
}
|
|
@@ -337,9 +279,9 @@ async function createConfig(paths, options) {
|
|
|
337
279
|
rules: loaders
|
|
338
280
|
},
|
|
339
281
|
output: {
|
|
340
|
-
uniqueName: options.
|
|
282
|
+
uniqueName: options.moduleFederationRemote?.name,
|
|
341
283
|
path: paths.targetDist,
|
|
342
|
-
publicPath: options.
|
|
284
|
+
publicPath: options.moduleFederationRemote ? "auto" : `${publicPath}/`,
|
|
343
285
|
filename: isDev ? "[name].js" : "static/[name].[contenthash:8].js",
|
|
344
286
|
chunkFilename: isDev ? "[name].chunk.js" : "static/[name].[contenthash:8].chunk.js",
|
|
345
287
|
...isDev ? {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var cliCommon = require('@backstage/cli-common');
|
|
4
4
|
|
|
5
5
|
function hasReactDomClient() {
|
|
6
6
|
try {
|
|
7
7
|
require.resolve("react-dom/client", {
|
|
8
|
-
paths: [
|
|
8
|
+
paths: [cliCommon.targetPaths.dir]
|
|
9
9
|
});
|
|
10
10
|
return true;
|
|
11
11
|
} catch {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('node:path');
|
|
4
4
|
var getPackages = require('@manypkg/get-packages');
|
|
5
|
-
var
|
|
5
|
+
var cliCommon = require('@backstage/cli-common');
|
|
6
6
|
|
|
7
7
|
async function createWorkspaceLinkingPlugins(bundler, workspace) {
|
|
8
8
|
const { packages: linkedPackages, root: linkedRoot } = await getPackages.getPackages(
|
|
@@ -23,7 +23,7 @@ async function createWorkspaceLinkingPlugins(bundler, workspace) {
|
|
|
23
23
|
/^react(?:-router)?(?:-dom)?$/,
|
|
24
24
|
(resource) => {
|
|
25
25
|
if (!path.relative(linkedRoot.dir, resource.context).startsWith("..")) {
|
|
26
|
-
resource.context =
|
|
26
|
+
resource.context = cliCommon.targetPaths.dir;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
)
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var entryPoints = require('../../../../lib/entryPoints.cjs.js');
|
|
3
|
+
var entryPoints = require('../entryPoints.cjs.js');
|
|
5
4
|
var typeDistProject = require('../../../../lib/typeDistProject.cjs.js');
|
|
5
|
+
var moduleFederationCommon = require('@backstage/module-federation-common');
|
|
6
|
+
var path = require('node:path');
|
|
7
|
+
var fs = require('fs-extra');
|
|
8
|
+
var chokidar = require('chokidar');
|
|
9
|
+
var PQueue = require('p-queue');
|
|
6
10
|
|
|
7
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
12
|
|
|
9
|
-
var
|
|
13
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
14
|
+
var chokidar__default = /*#__PURE__*/_interopDefaultCompat(chokidar);
|
|
15
|
+
var PQueue__default = /*#__PURE__*/_interopDefaultCompat(PQueue);
|
|
10
16
|
|
|
11
|
-
async function
|
|
12
|
-
if (!isModuleFederationRemote && !process.env.EXPERIMENTAL_MODULE_FEDERATION) {
|
|
13
|
-
return void 0;
|
|
14
|
-
}
|
|
15
|
-
console.log(
|
|
16
|
-
chalk__default.default.yellow(
|
|
17
|
-
`\u26A0\uFE0F WARNING: Module federation is experimental and will receive immediate breaking changes in the future.`
|
|
18
|
-
)
|
|
19
|
-
);
|
|
17
|
+
async function getModuleFederationRemoteOptions(packageJson, packageDir) {
|
|
20
18
|
let exposes;
|
|
21
19
|
const packageRole = packageJson.backstage?.role;
|
|
22
|
-
if (
|
|
20
|
+
if (packageJson.exports && packageRole) {
|
|
23
21
|
const project = await typeDistProject.createTypeDistProject();
|
|
24
22
|
exposes = Object.fromEntries(
|
|
25
23
|
entryPoints.readEntryPoints(packageJson).filter((ep) => {
|
|
@@ -39,14 +37,99 @@ async function getModuleFederationOptions(packageJson, packageDir, isModuleFeder
|
|
|
39
37
|
);
|
|
40
38
|
}
|
|
41
39
|
return {
|
|
42
|
-
mode: isModuleFederationRemote ? "remote" : "host",
|
|
43
40
|
// The default output mode requires the name to be a usable as a code
|
|
44
41
|
// symbol, there might be better options here but for now we need to
|
|
45
42
|
// sanitize the name.
|
|
46
43
|
name: packageJson.name.replaceAll("@", "").replaceAll("/", "__").replaceAll("-", "_"),
|
|
47
|
-
exposes
|
|
44
|
+
exposes,
|
|
45
|
+
sharedDependencies: moduleFederationCommon.defaultRemoteSharedDependencies()
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function prepareRuntimeSharedDependenciesScript(hostSharedDependencies) {
|
|
49
|
+
const items = Object.entries(hostSharedDependencies).map(
|
|
50
|
+
([name, sharedDep]) => {
|
|
51
|
+
if (!sharedDep.version) {
|
|
52
|
+
throw new Error(`Version is required for shared dependency '${name}'`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
name,
|
|
56
|
+
version: sharedDep.version,
|
|
57
|
+
lib: name,
|
|
58
|
+
// Coverted into import below
|
|
59
|
+
shareConfig: {
|
|
60
|
+
singleton: sharedDep.singleton,
|
|
61
|
+
requiredVersion: sharedDep.requiredVersion,
|
|
62
|
+
eager: sharedDep.eager
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
return `window['${moduleFederationCommon.BACKSTAGE_RUNTIME_SHARED_DEPENDENCIES_GLOBAL}'] = ${JSON.stringify(
|
|
68
|
+
{ items, version: "v1" },
|
|
69
|
+
null,
|
|
70
|
+
2
|
|
71
|
+
).replace(
|
|
72
|
+
/"lib": ("[^"]+")/gm,
|
|
73
|
+
(_, name) => `"lib": () => import(${name})`
|
|
74
|
+
)};`;
|
|
75
|
+
}
|
|
76
|
+
const RUNTIME_SHARED_DEPENDENCIES_MODULE_NAME = "__backstage-module-federation-runtime-shared-dependencies__";
|
|
77
|
+
const writeQueue = new PQueue__default.default({ concurrency: 1 });
|
|
78
|
+
async function writeRuntimeSharedDependenciesModule(targetPath, runtimeSharedDependencies) {
|
|
79
|
+
const script = prepareRuntimeSharedDependenciesScript(
|
|
80
|
+
runtimeSharedDependencies
|
|
81
|
+
);
|
|
82
|
+
await writeQueue.add(async () => {
|
|
83
|
+
const path$1 = path.join(
|
|
84
|
+
targetPath,
|
|
85
|
+
"node_modules",
|
|
86
|
+
`${RUNTIME_SHARED_DEPENDENCIES_MODULE_NAME}.js`
|
|
87
|
+
);
|
|
88
|
+
await fs__default.default.ensureDir(path.dirname(path$1));
|
|
89
|
+
await fs__default.default.writeFile(path$1, script);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function resolveSharedDependencyVersions(targetPath, hostSharedDependencies) {
|
|
93
|
+
return Object.fromEntries(
|
|
94
|
+
Object.entries(hostSharedDependencies).filter(([_, sharedDep]) => sharedDep !== void 0).flatMap(([importPath, sharedDep]) => {
|
|
95
|
+
const moduleName = importPath.startsWith("@") ? importPath.split("/").slice(0, 2).join("/") : importPath.split("/")[0];
|
|
96
|
+
let version;
|
|
97
|
+
try {
|
|
98
|
+
const packagePath = require.resolve(`${moduleName}/package.json`, {
|
|
99
|
+
paths: [targetPath]
|
|
100
|
+
});
|
|
101
|
+
version = require(packagePath).version;
|
|
102
|
+
} catch (e) {
|
|
103
|
+
console.log(
|
|
104
|
+
`Skipping module federation shared dependency '${importPath}' because it could not be resolved.`
|
|
105
|
+
);
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
return [[importPath, { ...sharedDep, version }]];
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
async function createRuntimeSharedDependenciesEntryPoint(options) {
|
|
113
|
+
const { targetPath, watch } = options;
|
|
114
|
+
const doWriteSharedDependenciesModule = async () => {
|
|
115
|
+
const sharedDependencies = moduleFederationCommon.defaultHostSharedDependencies();
|
|
116
|
+
await writeRuntimeSharedDependenciesModule(
|
|
117
|
+
targetPath,
|
|
118
|
+
resolveSharedDependencyVersions(targetPath, sharedDependencies)
|
|
119
|
+
);
|
|
48
120
|
};
|
|
121
|
+
if (watch) {
|
|
122
|
+
const watcher = chokidar__default.default.watch(path.resolve(targetPath, "package.json"));
|
|
123
|
+
watcher.on("change", async () => {
|
|
124
|
+
await doWriteSharedDependenciesModule();
|
|
125
|
+
watch();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
await doWriteSharedDependenciesModule();
|
|
129
|
+
return [RUNTIME_SHARED_DEPENDENCIES_MODULE_NAME];
|
|
49
130
|
}
|
|
50
131
|
|
|
51
|
-
exports.
|
|
132
|
+
exports.createRuntimeSharedDependenciesEntryPoint = createRuntimeSharedDependenciesEntryPoint;
|
|
133
|
+
exports.getModuleFederationRemoteOptions = getModuleFederationRemoteOptions;
|
|
134
|
+
exports.prepareRuntimeSharedDependenciesScript = prepareRuntimeSharedDependenciesScript;
|
|
52
135
|
//# sourceMappingURL=moduleFederation.cjs.js.map
|
|
@@ -5,7 +5,7 @@ var chokidar = require('chokidar');
|
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
6
|
var PQueue = require('p-queue');
|
|
7
7
|
var path = require('node:path');
|
|
8
|
-
var
|
|
8
|
+
var cliCommon = require('@backstage/cli-common');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
11
|
|
|
@@ -96,7 +96,7 @@ async function createDetectedModulesEntryPoint(options) {
|
|
|
96
96
|
return [];
|
|
97
97
|
}
|
|
98
98
|
const legacyDetectedModulesPath = path.join(
|
|
99
|
-
|
|
99
|
+
cliCommon.targetPaths.rootDir,
|
|
100
100
|
"node_modules",
|
|
101
101
|
`${DETECTED_MODULES_MODULE_NAME}.js`
|
|
102
102
|
);
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('fs-extra');
|
|
4
4
|
var path = require('node:path');
|
|
5
|
-
var
|
|
5
|
+
var cliCommon = require('@backstage/cli-common');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
8
|
|
|
9
9
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
10
10
|
|
|
11
11
|
function resolveBundlingPaths(options) {
|
|
12
|
-
const { entry, targetDir =
|
|
12
|
+
const { entry, targetDir = cliCommon.targetPaths.dir } = options;
|
|
13
13
|
const resolveTargetModule = (pathString) => {
|
|
14
14
|
for (const ext of ["mjs", "js", "ts", "tsx", "jsx"]) {
|
|
15
15
|
const filePath = path.resolve(targetDir, `${pathString}.${ext}`);
|
|
@@ -26,7 +26,9 @@ function resolveBundlingPaths(options) {
|
|
|
26
26
|
} else {
|
|
27
27
|
targetHtml = path.resolve(targetDir, `${entry}.html`);
|
|
28
28
|
if (!fs__default.default.pathExistsSync(targetHtml)) {
|
|
29
|
-
targetHtml =
|
|
29
|
+
targetHtml = cliCommon.findOwnPaths(__dirname).resolve(
|
|
30
|
+
"templates/serve_index.html"
|
|
31
|
+
);
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
const targetRunFile = path.resolve(targetDir, "src/run.ts");
|
|
@@ -41,10 +43,10 @@ function resolveBundlingPaths(options) {
|
|
|
41
43
|
targetSrc: path.resolve(targetDir, "src"),
|
|
42
44
|
targetDev: path.resolve(targetDir, "dev"),
|
|
43
45
|
targetEntry: resolveTargetModule(entry),
|
|
44
|
-
targetTsConfig:
|
|
46
|
+
targetTsConfig: cliCommon.targetPaths.resolveRoot("tsconfig.json"),
|
|
45
47
|
targetPackageJson: path.resolve(targetDir, "package.json"),
|
|
46
|
-
rootNodeModules:
|
|
47
|
-
root:
|
|
48
|
+
rootNodeModules: cliCommon.targetPaths.resolveRoot("node_modules"),
|
|
49
|
+
root: cliCommon.targetPaths.rootDir
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
async function resolveOptionalBundlingPaths(options) {
|
|
@@ -6,11 +6,12 @@ var path = require('node:path');
|
|
|
6
6
|
var openBrowser = require('react-dev-utils/openBrowser');
|
|
7
7
|
var core = require('@rspack/core');
|
|
8
8
|
var devServer = require('@rspack/dev-server');
|
|
9
|
-
var
|
|
9
|
+
var cliCommon = require('@backstage/cli-common');
|
|
10
10
|
var config = require('../../../config/lib/config.cjs.js');
|
|
11
11
|
var config$1 = require('./config.cjs.js');
|
|
12
12
|
var packageDetection = require('./packageDetection.cjs.js');
|
|
13
13
|
var paths = require('./paths.cjs.js');
|
|
14
|
+
var moduleFederation = require('./moduleFederation.cjs.js');
|
|
14
15
|
|
|
15
16
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
16
17
|
|
|
@@ -19,8 +20,8 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
|
19
20
|
var openBrowser__default = /*#__PURE__*/_interopDefaultCompat(openBrowser);
|
|
20
21
|
|
|
21
22
|
async function serveBundle(options) {
|
|
22
|
-
const paths$
|
|
23
|
-
const targetPkg = await fs__default.default.readJson(paths$
|
|
23
|
+
const paths$1 = paths.resolveBundlingPaths(options);
|
|
24
|
+
const targetPkg = await fs__default.default.readJson(paths$1.targetPackageJson);
|
|
24
25
|
if (options.verifyVersions) {
|
|
25
26
|
if (targetPkg.dependencies?.["react-router"]?.includes("beta") || targetPkg.dependencies?.["react-router-dom"]?.includes("beta")) {
|
|
26
27
|
console.warn(
|
|
@@ -34,7 +35,7 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
34
35
|
}
|
|
35
36
|
checkReactVersion();
|
|
36
37
|
const { name } = await fs__default.default.readJson(
|
|
37
|
-
path.resolve(options.targetDir ??
|
|
38
|
+
path.resolve(options.targetDir ?? cliCommon.targetPaths.dir, "package.json")
|
|
38
39
|
);
|
|
39
40
|
let devServer$1 = void 0;
|
|
40
41
|
let latestFrontendAppConfigs = [];
|
|
@@ -78,14 +79,20 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
78
79
|
);
|
|
79
80
|
}
|
|
80
81
|
const { frontendConfig, fullConfig } = cliConfig;
|
|
81
|
-
const url = config$1.resolveBaseUrl(frontendConfig, options.
|
|
82
|
+
const url = config$1.resolveBaseUrl(frontendConfig, options.moduleFederationRemote);
|
|
82
83
|
const { host, port } = config$1.resolveEndpoint(
|
|
83
84
|
frontendConfig,
|
|
84
|
-
options.
|
|
85
|
+
options.moduleFederationRemote
|
|
85
86
|
);
|
|
86
87
|
const detectedModulesEntryPoint = await packageDetection.createDetectedModulesEntryPoint({
|
|
87
88
|
config: fullConfig,
|
|
88
|
-
targetPath: paths$
|
|
89
|
+
targetPath: paths$1.targetPath,
|
|
90
|
+
watch() {
|
|
91
|
+
triggerReload();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const moduleFederationSharedDependenciesEntryPoint = await moduleFederation.createRuntimeSharedDependenciesEntryPoint({
|
|
95
|
+
targetPath: paths$1.targetPath,
|
|
89
96
|
watch() {
|
|
90
97
|
triggerReload();
|
|
91
98
|
}
|
|
@@ -102,10 +109,13 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
102
109
|
return latestFrontendAppConfigs;
|
|
103
110
|
}
|
|
104
111
|
};
|
|
105
|
-
const config$2 = await config$1.createConfig(paths$
|
|
112
|
+
const config$2 = await config$1.createConfig(paths$1, {
|
|
106
113
|
...commonConfigOptions,
|
|
107
|
-
additionalEntryPoints:
|
|
108
|
-
|
|
114
|
+
additionalEntryPoints: [
|
|
115
|
+
...detectedModulesEntryPoint,
|
|
116
|
+
...moduleFederationSharedDependenciesEntryPoint
|
|
117
|
+
],
|
|
118
|
+
moduleFederationRemote: options.moduleFederationRemote
|
|
109
119
|
});
|
|
110
120
|
const bundler = webpack ?? core.rspack;
|
|
111
121
|
const DevServer = webpack ? require("webpack-dev-server") : devServer.RspackDevServer;
|
|
@@ -131,11 +141,11 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
131
141
|
publicPath: config$2.output?.publicPath,
|
|
132
142
|
stats: "errors-warnings"
|
|
133
143
|
},
|
|
134
|
-
static: paths$
|
|
144
|
+
static: paths$1.targetPublic ? {
|
|
135
145
|
publicPath: config$2.output?.publicPath,
|
|
136
|
-
directory: paths$
|
|
146
|
+
directory: paths$1.targetPublic
|
|
137
147
|
} : void 0,
|
|
138
|
-
historyApiFallback: options.
|
|
148
|
+
historyApiFallback: options.moduleFederationRemote ? false : {
|
|
139
149
|
// Paths with dots should still use the history fallback.
|
|
140
150
|
// See https://github.com/facebookincubator/create-react-app/issues/387.
|
|
141
151
|
disableDotRule: true,
|
|
@@ -198,7 +208,7 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
198
208
|
function checkReactVersion() {
|
|
199
209
|
try {
|
|
200
210
|
const reactPkgPath = require.resolve("react/package.json", {
|
|
201
|
-
paths: [
|
|
211
|
+
paths: [cliCommon.targetPaths.rootDir]
|
|
202
212
|
});
|
|
203
213
|
const reactPkg = require(reactPkgPath);
|
|
204
214
|
if (reactPkg.version.startsWith("16.")) {
|
|
@@ -6,14 +6,12 @@ var path = require('node:path');
|
|
|
6
6
|
var os = require('node:os');
|
|
7
7
|
var tar = require('tar');
|
|
8
8
|
var partition = require('lodash/partition');
|
|
9
|
-
var paths = require('../../../../lib/paths.cjs.js');
|
|
10
9
|
var cliCommon = require('@backstage/cli-common');
|
|
11
10
|
var _package = require('../../../../packages/cli/package.json.cjs.js');
|
|
12
11
|
var packager = require('../builder/packager.cjs.js');
|
|
13
12
|
var types = require('../builder/types.cjs.js');
|
|
14
13
|
var productionPack = require('./productionPack.cjs.js');
|
|
15
14
|
var cliNode = require('@backstage/cli-node');
|
|
16
|
-
var parallel = require('../../../../lib/parallel.cjs.js');
|
|
17
15
|
var typeDistProject = require('../../../../lib/typeDistProject.cjs.js');
|
|
18
16
|
|
|
19
17
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -111,7 +109,9 @@ async function createDistWorkspace(packageNames, options = {}) {
|
|
|
111
109
|
targetDir: pkg.dir,
|
|
112
110
|
packageJson: pkg.packageJson,
|
|
113
111
|
outputs,
|
|
114
|
-
logPrefix: `${chalk__default.default.cyan(
|
|
112
|
+
logPrefix: `${chalk__default.default.cyan(
|
|
113
|
+
path.relative(cliCommon.targetPaths.rootDir, pkg.dir)
|
|
114
|
+
)}: `,
|
|
115
115
|
minify: options.minify,
|
|
116
116
|
workspacePackages: packages
|
|
117
117
|
});
|
|
@@ -119,7 +119,7 @@ async function createDistWorkspace(packageNames, options = {}) {
|
|
|
119
119
|
}
|
|
120
120
|
await packager.buildPackages(standardBuilds);
|
|
121
121
|
if (customBuild.length > 0) {
|
|
122
|
-
await
|
|
122
|
+
await cliNode.runConcurrentTasks({
|
|
123
123
|
items: customBuild,
|
|
124
124
|
worker: async ({ name, dir, args }) => {
|
|
125
125
|
await cliCommon.run(["yarn", "run", "build", ...args || []], {
|
|
@@ -141,11 +141,11 @@ async function createDistWorkspace(packageNames, options = {}) {
|
|
|
141
141
|
for (const file of files) {
|
|
142
142
|
const src = typeof file === "string" ? file : file.src;
|
|
143
143
|
const dest = typeof file === "string" ? file : file.dest;
|
|
144
|
-
await fs__default.default.copy(
|
|
144
|
+
await fs__default.default.copy(cliCommon.targetPaths.resolveRoot(src), path.resolve(targetDir, dest));
|
|
145
145
|
}
|
|
146
146
|
if (options.skeleton) {
|
|
147
147
|
const skeletonFiles = targets.map((target) => {
|
|
148
|
-
const dir = path.relative(
|
|
148
|
+
const dir = path.relative(cliCommon.targetPaths.rootDir, target.dir);
|
|
149
149
|
return path.join(dir, "package.json");
|
|
150
150
|
}).sort();
|
|
151
151
|
await tar__namespace.create(
|
|
@@ -175,7 +175,7 @@ async function moveToDistWorkspace(workspaceDir, localPackages, alwaysPack, enab
|
|
|
175
175
|
await Promise.all(
|
|
176
176
|
fastPackPackages.map(async (target) => {
|
|
177
177
|
console.log(`Moving ${target.name} into dist workspace`);
|
|
178
|
-
const outputDir = path.relative(
|
|
178
|
+
const outputDir = path.relative(cliCommon.targetPaths.rootDir, target.dir);
|
|
179
179
|
const absoluteOutputPath = path.resolve(workspaceDir, outputDir);
|
|
180
180
|
await productionPack.productionPack({
|
|
181
181
|
packageDir: target.dir,
|
|
@@ -190,7 +190,7 @@ async function moveToDistWorkspace(workspaceDir, localPackages, alwaysPack, enab
|
|
|
190
190
|
await cliCommon.run(["yarn", "pack", "--filename", archivePath], {
|
|
191
191
|
cwd: target.dir
|
|
192
192
|
}).waitForExit();
|
|
193
|
-
const outputDir = path.relative(
|
|
193
|
+
const outputDir = path.relative(cliCommon.targetPaths.rootDir, target.dir);
|
|
194
194
|
const absoluteOutputPath = path.resolve(workspaceDir, outputDir);
|
|
195
195
|
await fs__default.default.ensureDir(absoluteOutputPath);
|
|
196
196
|
await tar__namespace.extract({
|
|
@@ -223,7 +223,7 @@ async function moveToDistWorkspace(workspaceDir, localPackages, alwaysPack, enab
|
|
|
223
223
|
for (const target of unsafePackages) {
|
|
224
224
|
await pack(target, `temp-package.tgz`);
|
|
225
225
|
}
|
|
226
|
-
await
|
|
226
|
+
await cliNode.runConcurrentTasks({
|
|
227
227
|
items: safePackages.map((target, index) => ({ target, index })),
|
|
228
228
|
worker: async ({ target, index }) => {
|
|
229
229
|
await pack(target, `temp-package-${index}.tgz`);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var fs = require('fs-extra');
|
|
4
4
|
var npmPackList = require('npm-packlist');
|
|
5
5
|
var path = require('node:path');
|
|
6
|
-
var entryPoints = require('
|
|
6
|
+
var entryPoints = require('../entryPoints.cjs.js');
|
|
7
7
|
var typeDistProject = require('../../../../lib/typeDistProject.cjs.js');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var fs = require('fs-extra');
|
|
4
|
-
var
|
|
4
|
+
var cliCommon = require('@backstage/cli-common');
|
|
5
5
|
var cliNode = require('@backstage/cli-node');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -12,7 +12,7 @@ async function findRoleFromCommand(opts) {
|
|
|
12
12
|
if (opts.role) {
|
|
13
13
|
return cliNode.PackageRoles.getRoleInfo(opts.role)?.role;
|
|
14
14
|
}
|
|
15
|
-
const pkg = await fs__default.default.readJson(
|
|
15
|
+
const pkg = await fs__default.default.readJson(cliCommon.targetPaths.resolve("package.json"));
|
|
16
16
|
const info = cliNode.PackageRoles.getRoleFromPackage(pkg);
|
|
17
17
|
if (!info) {
|
|
18
18
|
throw new Error(`Target package must have 'backstage.role' set`);
|
|
@@ -7,7 +7,7 @@ var ServerDataStore = require('../ipc/ServerDataStore.cjs.js');
|
|
|
7
7
|
var debounce = require('lodash/debounce');
|
|
8
8
|
var node_url = require('node:url');
|
|
9
9
|
var path = require('node:path');
|
|
10
|
-
var
|
|
10
|
+
var cliCommon = require('@backstage/cli-common');
|
|
11
11
|
var spawn = require('cross-spawn');
|
|
12
12
|
|
|
13
13
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -86,7 +86,7 @@ async function runBackend(options) {
|
|
|
86
86
|
...process.env,
|
|
87
87
|
BACKSTAGE_CLI_LINKED_WORKSPACE: options.linkedWorkspace,
|
|
88
88
|
BACKSTAGE_CLI_CHANNEL: "1",
|
|
89
|
-
ESBK_TSCONFIG_PATH:
|
|
89
|
+
ESBK_TSCONFIG_PATH: cliCommon.targetPaths.resolveRoot("tsconfig.json")
|
|
90
90
|
},
|
|
91
91
|
serialization: "advanced"
|
|
92
92
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var configLoader = require('@backstage/config-loader');
|
|
4
4
|
var config = require('@backstage/config');
|
|
5
|
-
var
|
|
5
|
+
var cliCommon = require('@backstage/cli-common');
|
|
6
6
|
var getPackages = require('@manypkg/get-packages');
|
|
7
7
|
var cliNode = require('@backstage/cli-node');
|
|
8
8
|
var path = require('node:path');
|
|
9
9
|
|
|
10
10
|
async function loadCliConfig(options) {
|
|
11
|
-
const targetDir = options.targetDir ??
|
|
11
|
+
const targetDir = options.targetDir ?? cliCommon.targetPaths.dir;
|
|
12
12
|
const { packages } = await getPackages.getPackages(targetDir);
|
|
13
13
|
let localPackageNames;
|
|
14
14
|
if (options.fromPackage) {
|
|
@@ -31,14 +31,14 @@ async function loadCliConfig(options) {
|
|
|
31
31
|
const schema = await configLoader.loadConfigSchema({
|
|
32
32
|
dependencies: localPackageNames,
|
|
33
33
|
// Include the package.json in the project root if it exists
|
|
34
|
-
packagePaths: [
|
|
34
|
+
packagePaths: [cliCommon.targetPaths.resolveRoot("package.json")],
|
|
35
35
|
noUndeclaredProperties: options.strict
|
|
36
36
|
});
|
|
37
37
|
const source = configLoader.ConfigSources.default({
|
|
38
38
|
allowMissingDefaultConfig: true,
|
|
39
39
|
substitutionFunc: options.mockEnv ? async (name) => process.env[name] || "x" : void 0,
|
|
40
40
|
watch: Boolean(options.watch),
|
|
41
|
-
rootDir:
|
|
41
|
+
rootDir: cliCommon.targetPaths.rootDir,
|
|
42
42
|
argv: options.args.flatMap((t) => ["--config", path.resolve(targetDir, t)])
|
|
43
43
|
});
|
|
44
44
|
const appConfigs = await new Promise((resolve, reject) => {
|