@backstage/cli 0.36.0-next.1 → 0.36.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 +110 -0
- package/config/eslint-factory.js +1 -0
- package/config/getJestEnvironment.js +7 -29
- package/config/jest-environment-jsdom/index.js +9 -43
- package/config/jest.js +7 -401
- package/config/jestCacheResultProcessor.cjs +10 -6
- package/config/jestCachingModuleLoader.js +11 -19
- package/config/jestFileTransform.js +11 -28
- package/config/jestRejectNetworkRequests.js +10 -53
- package/config/jestSucraseTransform.js +10 -70
- package/config/jestSwcTransform.js +10 -27
- package/config/jestYamlTransform.js +11 -24
- package/config/nodeTransform.cjs +10 -70
- package/config/nodeTransformHooks.mjs +4 -278
- package/config/webpack-public-path.js +10 -14
- package/dist/cli-internal/src/InternalCliModule.cjs.js +11 -0
- package/dist/cli-internal/src/InternalCommandNode.cjs.js +25 -0
- package/dist/cli-internal/src/knownPluginPackages.cjs.js +40 -0
- package/dist/index.cjs.js +21 -10
- package/dist/wiring/CliInitializer.cjs.js +61 -20
- package/dist/wiring/CommandGraph.cjs.js +81 -23
- package/dist/wiring/discoverCliModules.cjs.js +44 -0
- package/package.json +27 -154
- package/dist/modules/build/commands/buildWorkspace.cjs.js +0 -24
- package/dist/modules/build/commands/package/build/command.cjs.js +0 -89
- package/dist/modules/build/commands/package/build/index.cjs.js +0 -8
- package/dist/modules/build/commands/package/clean.cjs.js +0 -21
- package/dist/modules/build/commands/package/postpack.cjs.js +0 -15
- package/dist/modules/build/commands/package/prepack.cjs.js +0 -29
- package/dist/modules/build/commands/package/start/command.cjs.js +0 -23
- package/dist/modules/build/commands/package/start/index.cjs.js +0 -8
- package/dist/modules/build/commands/package/start/resolveLinkedWorkspace.cjs.js +0 -34
- package/dist/modules/build/commands/package/start/startBackend.cjs.js +0 -46
- package/dist/modules/build/commands/package/start/startFrontend.cjs.js +0 -50
- package/dist/modules/build/commands/package/start/startPackage.cjs.js +0 -53
- package/dist/modules/build/commands/repo/build.cjs.js +0 -114
- package/dist/modules/build/commands/repo/clean.cjs.js +0 -41
- package/dist/modules/build/commands/repo/start.cjs.js +0 -150
- package/dist/modules/build/index.cjs.js +0 -192
- package/dist/modules/build/lib/buildBackend.cjs.js +0 -81
- package/dist/modules/build/lib/buildFrontend.cjs.js +0 -50
- package/dist/modules/build/lib/builder/config.cjs.js +0 -257
- package/dist/modules/build/lib/builder/packager.cjs.js +0 -131
- package/dist/modules/build/lib/builder/plugins.cjs.js +0 -125
- package/dist/modules/build/lib/builder/types.cjs.js +0 -10
- package/dist/modules/build/lib/bundler/ConfigInjectingHtmlWebpackPlugin.cjs.js +0 -43
- package/dist/modules/build/lib/bundler/bundle.cjs.js +0 -189
- package/dist/modules/build/lib/bundler/config.cjs.js +0 -308
- package/dist/modules/build/lib/bundler/hasReactDomClient.cjs.js +0 -17
- package/dist/modules/build/lib/bundler/linkWorkspaces.cjs.js +0 -34
- package/dist/modules/build/lib/bundler/moduleFederation.cjs.js +0 -135
- package/dist/modules/build/lib/bundler/optimization.cjs.js +0 -68
- package/dist/modules/build/lib/bundler/packageDetection.cjs.js +0 -124
- package/dist/modules/build/lib/bundler/paths.cjs.js +0 -62
- package/dist/modules/build/lib/bundler/server.cjs.js +0 -231
- package/dist/modules/build/lib/bundler/transforms.cjs.js +0 -145
- package/dist/modules/build/lib/config.cjs.js +0 -94
- package/dist/modules/build/lib/entryPoints.cjs.js +0 -49
- package/dist/modules/build/lib/ipc/IpcServer.cjs.js +0 -60
- package/dist/modules/build/lib/ipc/ServerDataStore.cjs.js +0 -36
- package/dist/modules/build/lib/optionsParser.cjs.js +0 -37
- package/dist/modules/build/lib/packager/createDistWorkspace.cjs.js +0 -235
- package/dist/modules/build/lib/packager/productionPack.cjs.js +0 -160
- package/dist/modules/build/lib/publishing.cjs.js +0 -40
- package/dist/modules/build/lib/role.cjs.js +0 -24
- package/dist/modules/build/lib/runner/runBackend.cjs.js +0 -136
- package/dist/modules/build/lib/typeDistProject.cjs.js +0 -89
- package/dist/modules/build/lib/urls.cjs.js +0 -13
- package/dist/modules/config/commands/docs.cjs.js +0 -62
- package/dist/modules/config/commands/print.cjs.js +0 -80
- package/dist/modules/config/commands/schema.cjs.js +0 -55
- package/dist/modules/config/commands/validate.cjs.js +0 -49
- package/dist/modules/config/index.cjs.js +0 -51
- package/dist/modules/config/lib/config.cjs.js +0 -94
- package/dist/modules/create-github-app/commands/create-github-app/GithubCreateAppServer.cjs.js +0 -127
- package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +0 -115
- package/dist/modules/create-github-app/index.cjs.js +0 -27
- package/dist/modules/info/commands/info.cjs.js +0 -181
- package/dist/modules/info/index.cjs.js +0 -19
- package/dist/modules/lint/commands/package/lint.cjs.js +0 -46
- package/dist/modules/lint/commands/repo/lint.cjs.js +0 -212
- package/dist/modules/lint/index.cjs.js +0 -82
- package/dist/modules/lint/lib/optionsParser.cjs.js +0 -37
- package/dist/modules/maintenance/commands/repo/fix.cjs.js +0 -400
- package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +0 -74
- package/dist/modules/maintenance/index.cjs.js +0 -42
- package/dist/modules/migrate/commands/packageExports.cjs.js +0 -15
- package/dist/modules/migrate/commands/packageLintConfigs.cjs.js +0 -77
- package/dist/modules/migrate/commands/packageRole.cjs.js +0 -57
- package/dist/modules/migrate/commands/packageScripts.cjs.js +0 -87
- package/dist/modules/migrate/commands/reactRouterDeps.cjs.js +0 -51
- package/dist/modules/migrate/commands/versions/bump.cjs.js +0 -373
- package/dist/modules/migrate/commands/versions/migrate.cjs.js +0 -112
- package/dist/modules/migrate/index.cjs.js +0 -82
- package/dist/modules/migrate/lib/utils.cjs.js +0 -44
- package/dist/modules/migrate/lib/versioning/packages.cjs.js +0 -71
- package/dist/modules/migrate/lib/versioning/yarn.cjs.js +0 -28
- package/dist/modules/new/commands/new.cjs.js +0 -60
- package/dist/modules/new/index.cjs.js +0 -68
- package/dist/modules/new/lib/codeowners/codeowners.cjs.js +0 -92
- package/dist/modules/new/lib/createNewPackage.cjs.js +0 -32
- package/dist/modules/new/lib/defaultTemplates.cjs.js +0 -17
- package/dist/modules/new/lib/execution/PortableTemplater.cjs.js +0 -89
- package/dist/modules/new/lib/execution/executePortableTemplate.cjs.js +0 -66
- package/dist/modules/new/lib/execution/installNewPackage.cjs.js +0 -127
- package/dist/modules/new/lib/execution/writeTemplateContents.cjs.js +0 -116
- package/dist/modules/new/lib/preparation/collectPortableTemplateInput.cjs.js +0 -157
- package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +0 -81
- package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +0 -132
- package/dist/modules/new/lib/preparation/resolvePackageParams.cjs.js +0 -40
- package/dist/modules/new/lib/preparation/selectTemplateInteractively.cjs.js +0 -38
- package/dist/modules/new/lib/tasks.cjs.js +0 -51
- package/dist/modules/new/lib/types.cjs.js +0 -19
- package/dist/modules/new/lib/version.cjs.js +0 -91
- package/dist/modules/test/commands/package/test.cjs.js +0 -65
- package/dist/modules/test/commands/repo/test.cjs.js +0 -288
- package/dist/modules/test/index.cjs.js +0 -54
- package/dist/modules/translations/commands/export.cjs.js +0 -127
- package/dist/modules/translations/commands/import.cjs.js +0 -164
- package/dist/modules/translations/index.cjs.js +0 -24
- package/dist/modules/translations/lib/discoverPackages.cjs.js +0 -121
- package/dist/modules/translations/lib/extractTranslations.cjs.js +0 -71
- package/dist/modules/translations/lib/messageFilePath.cjs.js +0 -43
- package/dist/packages/backend-defaults/package.json.cjs.js +0 -6
- package/dist/packages/backend-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/backend-test-utils/package.json.cjs.js +0 -6
- package/dist/packages/catalog-client/package.json.cjs.js +0 -6
- package/dist/packages/cli/package.json.cjs.js +0 -156
- package/dist/packages/config/package.json.cjs.js +0 -6
- package/dist/packages/core-app-api/package.json.cjs.js +0 -6
- package/dist/packages/core-components/package.json.cjs.js +0 -6
- package/dist/packages/core-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/dev-utils/package.json.cjs.js +0 -6
- package/dist/packages/errors/package.json.cjs.js +0 -6
- package/dist/packages/frontend-defaults/package.json.cjs.js +0 -6
- package/dist/packages/frontend-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/frontend-plugin-api/src/routing/describeParentCallSite.cjs.js +0 -26
- package/dist/packages/frontend-test-utils/package.json.cjs.js +0 -6
- package/dist/packages/test-utils/package.json.cjs.js +0 -6
- package/dist/packages/theme/package.json.cjs.js +0 -6
- package/dist/packages/types/package.json.cjs.js +0 -6
- package/dist/plugins/auth-backend/package.json.cjs.js +0 -6
- package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +0 -6
- package/dist/plugins/catalog-node/package.json.cjs.js +0 -6
- package/dist/plugins/scaffolder-node/package.json.cjs.js +0 -6
- package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +0 -6
- package/dist/wiring/CommandRegistry.cjs.js +0 -14
- package/dist/wiring/factory.cjs.js +0 -15
- package/dist/wiring/lazy.cjs.js +0 -22
- package/dist/wiring/types.cjs.js +0 -11
- package/templates/backend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/backend-plugin/README.md.hbs +0 -28
- package/templates/backend-plugin/dev/index.ts.hbs +0 -60
- package/templates/backend-plugin/package.json.hbs +0 -44
- package/templates/backend-plugin/portable-template.yaml +0 -5
- package/templates/backend-plugin/src/index.ts.hbs +0 -1
- package/templates/backend-plugin/src/plugin.test.ts.hbs +0 -129
- package/templates/backend-plugin/src/plugin.ts.hbs +0 -32
- package/templates/backend-plugin/src/router.test.ts +0 -67
- package/templates/backend-plugin/src/router.ts +0 -51
- package/templates/backend-plugin/src/services/TodoListService.ts +0 -155
- package/templates/backend-plugin/src/setupTests.ts +0 -1
- package/templates/backend-plugin-module/.eslintrc.js.hbs +0 -1
- package/templates/backend-plugin-module/README.md.hbs +0 -5
- package/templates/backend-plugin-module/package.json.hbs +0 -34
- package/templates/backend-plugin-module/portable-template.yaml +0 -5
- package/templates/backend-plugin-module/src/index.ts.hbs +0 -8
- package/templates/backend-plugin-module/src/module.ts.hbs +0 -17
- package/templates/catalog-provider-module/.eslintrc.js.hbs +0 -1
- package/templates/catalog-provider-module/README.md.hbs +0 -5
- package/templates/catalog-provider-module/config.d.ts.hbs +0 -34
- package/templates/catalog-provider-module/package.json.hbs +0 -36
- package/templates/catalog-provider-module/portable-template.yaml +0 -9
- package/templates/catalog-provider-module/src/index.ts.hbs +0 -8
- package/templates/catalog-provider-module/src/module.ts.hbs +0 -29
- package/templates/catalog-provider-module/src/provider/readProviderConfigs.ts.hbs +0 -78
- package/templates/catalog-provider-module/src/provider/{{providerClass}}.test.ts.hbs +0 -18
- package/templates/catalog-provider-module/src/provider/{{providerClass}}.ts.hbs +0 -109
- package/templates/frontend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/frontend-plugin/README.md.hbs +0 -13
- package/templates/frontend-plugin/dev/index.tsx.hbs +0 -11
- package/templates/frontend-plugin/package.json.hbs +0 -54
- package/templates/frontend-plugin/portable-template.yaml +0 -6
- package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
- package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
- package/templates/frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
- package/templates/frontend-plugin/src/index.ts.hbs +0 -1
- package/templates/frontend-plugin/src/plugin.test.ts.hbs +0 -7
- package/templates/frontend-plugin/src/plugin.ts.hbs +0 -22
- package/templates/frontend-plugin/src/routes.ts.hbs +0 -5
- package/templates/frontend-plugin/src/setupTests.ts +0 -1
- package/templates/new-frontend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/new-frontend-plugin/README.md.hbs +0 -20
- package/templates/new-frontend-plugin/dev/index.tsx +0 -10
- package/templates/new-frontend-plugin/package.json.hbs +0 -49
- package/templates/new-frontend-plugin/portable-template.yaml +0 -5
- package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
- package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
- package/templates/new-frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
- package/templates/new-frontend-plugin/src/index.ts.hbs +0 -1
- package/templates/new-frontend-plugin/src/plugin.test.ts.hbs +0 -7
- package/templates/new-frontend-plugin/src/plugin.tsx.hbs +0 -25
- package/templates/new-frontend-plugin/src/routes.ts +0 -3
- package/templates/new-frontend-plugin/src/setupTests.ts +0 -1
- package/templates/new-frontend-plugin-module/.eslintrc.js.hbs +0 -1
- package/templates/new-frontend-plugin-module/README.md.hbs +0 -5
- package/templates/new-frontend-plugin-module/package.json.hbs +0 -35
- package/templates/new-frontend-plugin-module/portable-template.yaml +0 -5
- package/templates/new-frontend-plugin-module/src/index.ts.hbs +0 -1
- package/templates/new-frontend-plugin-module/src/module.tsx.hbs +0 -8
- package/templates/new-frontend-plugin-module/src/setupTests.ts +0 -1
- package/templates/node-library/.eslintrc.js.hbs +0 -1
- package/templates/node-library/README.md.hbs +0 -12
- package/templates/node-library/package.json.hbs +0 -29
- package/templates/node-library/portable-template.yaml +0 -3
- package/templates/node-library/src/index.ts.hbs +0 -1
- package/templates/node-library/src/setupTests.ts +0 -1
- package/templates/plugin-common-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-common-library/README.md.hbs +0 -5
- package/templates/plugin-common-library/package.json.hbs +0 -31
- package/templates/plugin-common-library/portable-template.yaml +0 -3
- package/templates/plugin-common-library/src/index.ts.hbs +0 -19
- package/templates/plugin-common-library/src/setupTests.ts +0 -1
- package/templates/plugin-node-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-node-library/README.md.hbs +0 -5
- package/templates/plugin-node-library/package.json.hbs +0 -30
- package/templates/plugin-node-library/portable-template.yaml +0 -3
- package/templates/plugin-node-library/src/index.ts.hbs +0 -18
- package/templates/plugin-node-library/src/setupTests.ts +0 -1
- package/templates/plugin-web-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-web-library/README.md.hbs +0 -5
- package/templates/plugin-web-library/package.json.hbs +0 -42
- package/templates/plugin-web-library/portable-template.yaml +0 -3
- package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx +0 -17
- package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx +0 -28
- package/templates/plugin-web-library/src/components/ExampleComponent/index.ts +0 -2
- package/templates/plugin-web-library/src/components/index.ts +0 -5
- package/templates/plugin-web-library/src/hooks/index.ts +0 -5
- package/templates/plugin-web-library/src/hooks/useExample/index.ts +0 -1
- package/templates/plugin-web-library/src/hooks/useExample/useExample.ts +0 -15
- package/templates/plugin-web-library/src/index.ts.hbs +0 -12
- package/templates/plugin-web-library/src/setupTests.ts +0 -1
- package/templates/scaffolder-backend-module/.eslintrc.js.hbs +0 -1
- package/templates/scaffolder-backend-module/README.md.hbs +0 -5
- package/templates/scaffolder-backend-module/package.json.hbs +0 -36
- package/templates/scaffolder-backend-module/portable-template.yaml +0 -6
- package/templates/scaffolder-backend-module/src/actions/example.test.ts +0 -24
- package/templates/scaffolder-backend-module/src/actions/example.ts +0 -39
- package/templates/scaffolder-backend-module/src/index.ts.hbs +0 -8
- package/templates/scaffolder-backend-module/src/module.ts +0 -21
- package/templates/web-library/.eslintrc.js.hbs +0 -1
- package/templates/web-library/README.md.hbs +0 -12
- package/templates/web-library/package.json.hbs +0 -30
- package/templates/web-library/portable-template.yaml +0 -3
- package/templates/web-library/src/index.ts.hbs +0 -1
- package/templates/web-library/src/setupTests.ts +0 -1
- /package/dist/{packages/opaque-internal → opaque-internal}/src/OpaqueType.cjs.js +0 -0
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var yn = require('yn');
|
|
4
|
-
var fs = require('fs-extra');
|
|
5
|
-
var path = require('node:path');
|
|
6
|
-
var core = require('@rspack/core');
|
|
7
|
-
var FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
8
|
-
var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
9
|
-
var config = require('./config.cjs.js');
|
|
10
|
-
var paths = require('./paths.cjs.js');
|
|
11
|
-
var chalk = require('chalk');
|
|
12
|
-
var packageDetection = require('./packageDetection.cjs.js');
|
|
13
|
-
var moduleFederation = require('./moduleFederation.cjs.js');
|
|
14
|
-
|
|
15
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
16
|
-
|
|
17
|
-
var yn__default = /*#__PURE__*/_interopDefaultCompat(yn);
|
|
18
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
19
|
-
var formatWebpackMessages__default = /*#__PURE__*/_interopDefaultCompat(formatWebpackMessages);
|
|
20
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
21
|
-
|
|
22
|
-
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
23
|
-
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
24
|
-
function applyContextToError(error, moduleName) {
|
|
25
|
-
return `Failed to compile '${moduleName}':
|
|
26
|
-
${error}`;
|
|
27
|
-
}
|
|
28
|
-
async function buildBundle(options) {
|
|
29
|
-
const { statsJsonEnabled, schema: configSchema, webpack } = options;
|
|
30
|
-
const paths$1 = paths.resolveBundlingPaths(options);
|
|
31
|
-
const publicPaths = await paths.resolveOptionalBundlingPaths({
|
|
32
|
-
targetDir: options.targetDir,
|
|
33
|
-
entry: "src/index-public-experimental",
|
|
34
|
-
dist: "dist/public"
|
|
35
|
-
});
|
|
36
|
-
const commonConfigOptions = {
|
|
37
|
-
...options,
|
|
38
|
-
checksEnabled: false,
|
|
39
|
-
isDev: false,
|
|
40
|
-
getFrontendAppConfigs: () => options.frontendAppConfigs
|
|
41
|
-
};
|
|
42
|
-
const configs = [];
|
|
43
|
-
if (options.moduleFederationRemote) {
|
|
44
|
-
configs.push(await config.createConfig(paths$1, commonConfigOptions));
|
|
45
|
-
} else {
|
|
46
|
-
const detectedModulesEntryPoint = await packageDetection.createDetectedModulesEntryPoint({
|
|
47
|
-
config: options.fullConfig,
|
|
48
|
-
targetPath: paths$1.targetPath
|
|
49
|
-
});
|
|
50
|
-
const moduleFederationSharedDependenciesEntryPoint = await moduleFederation.createRuntimeSharedDependenciesEntryPoint({
|
|
51
|
-
targetPath: paths$1.targetPath
|
|
52
|
-
});
|
|
53
|
-
configs.push(
|
|
54
|
-
await config.createConfig(paths$1, {
|
|
55
|
-
...commonConfigOptions,
|
|
56
|
-
additionalEntryPoints: [
|
|
57
|
-
...detectedModulesEntryPoint,
|
|
58
|
-
...moduleFederationSharedDependenciesEntryPoint
|
|
59
|
-
],
|
|
60
|
-
appMode: publicPaths ? "protected" : "public"
|
|
61
|
-
})
|
|
62
|
-
);
|
|
63
|
-
if (publicPaths) {
|
|
64
|
-
console.log(
|
|
65
|
-
chalk__default.default.yellow(
|
|
66
|
-
`\u26A0\uFE0F WARNING: The app /public entry point is an experimental feature that may receive immediate breaking changes.`
|
|
67
|
-
)
|
|
68
|
-
);
|
|
69
|
-
configs.push(
|
|
70
|
-
await config.createConfig(publicPaths, {
|
|
71
|
-
...commonConfigOptions,
|
|
72
|
-
appMode: "public"
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const isCi = yn__default.default(process.env.CI, { default: false });
|
|
78
|
-
const previousFileSizes = await FileSizeReporter.measureFileSizesBeforeBuild(paths$1.targetDist);
|
|
79
|
-
const previousAuthSizes = publicPaths ? await FileSizeReporter.measureFileSizesBeforeBuild(publicPaths.targetDist) : void 0;
|
|
80
|
-
await fs__default.default.emptyDir(paths$1.targetDist);
|
|
81
|
-
if (paths$1.targetPublic) {
|
|
82
|
-
await fs__default.default.copy(paths$1.targetPublic, paths$1.targetDist, {
|
|
83
|
-
dereference: true,
|
|
84
|
-
filter: (file) => file !== paths$1.targetHtml
|
|
85
|
-
});
|
|
86
|
-
if (publicPaths) {
|
|
87
|
-
await fs__default.default.copy(paths$1.targetPublic, publicPaths.targetDist, {
|
|
88
|
-
dereference: true,
|
|
89
|
-
filter: (file) => file !== paths$1.targetHtml
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (configSchema) {
|
|
94
|
-
await fs__default.default.writeJson(
|
|
95
|
-
path.resolve(paths$1.targetDist, ".config-schema.json"),
|
|
96
|
-
configSchema.serialize(),
|
|
97
|
-
{ spaces: 2 }
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
if (webpack) {
|
|
101
|
-
console.log(chalk__default.default.yellow(`\u26A0\uFE0F WARNING: Using legacy WebPack bundler`));
|
|
102
|
-
}
|
|
103
|
-
const { stats } = await build(configs, isCi, webpack);
|
|
104
|
-
if (!stats) {
|
|
105
|
-
throw new Error("No stats returned");
|
|
106
|
-
}
|
|
107
|
-
const [mainStats, authStats] = stats.stats;
|
|
108
|
-
if (statsJsonEnabled) {
|
|
109
|
-
await require("bfj").write(
|
|
110
|
-
path.resolve(paths$1.targetDist, "bundle-stats.json"),
|
|
111
|
-
mainStats.toJson()
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
FileSizeReporter.printFileSizesAfterBuild(
|
|
115
|
-
mainStats,
|
|
116
|
-
previousFileSizes,
|
|
117
|
-
paths$1.targetDist,
|
|
118
|
-
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
119
|
-
WARN_AFTER_CHUNK_GZIP_SIZE
|
|
120
|
-
);
|
|
121
|
-
if (publicPaths && previousAuthSizes) {
|
|
122
|
-
FileSizeReporter.printFileSizesAfterBuild(
|
|
123
|
-
authStats,
|
|
124
|
-
previousAuthSizes,
|
|
125
|
-
publicPaths.targetDist,
|
|
126
|
-
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
127
|
-
WARN_AFTER_CHUNK_GZIP_SIZE
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async function build(configs, isCi, webpack) {
|
|
132
|
-
const bundler = webpack ?? core.rspack;
|
|
133
|
-
const stats = await new Promise((resolve, reject) => {
|
|
134
|
-
bundler(configs, (err, buildStats) => {
|
|
135
|
-
if (err) {
|
|
136
|
-
if (err.message) {
|
|
137
|
-
const { errors: errors2 } = formatWebpackMessages__default.default({
|
|
138
|
-
errors: [err.message],
|
|
139
|
-
warnings: new Array(),
|
|
140
|
-
_showErrors: true,
|
|
141
|
-
_showWarnings: true
|
|
142
|
-
});
|
|
143
|
-
throw new Error(errors2[0]);
|
|
144
|
-
} else {
|
|
145
|
-
reject(err);
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
resolve(buildStats);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
if (!stats) {
|
|
153
|
-
throw new Error("Failed to compile: No stats provided");
|
|
154
|
-
}
|
|
155
|
-
const serializedStats = stats.toJson({
|
|
156
|
-
all: false,
|
|
157
|
-
warnings: true,
|
|
158
|
-
errors: true
|
|
159
|
-
});
|
|
160
|
-
const { errors, warnings } = formatWebpackMessages__default.default({
|
|
161
|
-
errors: serializedStats.errors,
|
|
162
|
-
warnings: serializedStats.warnings
|
|
163
|
-
});
|
|
164
|
-
if (errors.length) {
|
|
165
|
-
const errorWithContext = applyContextToError(
|
|
166
|
-
errors[0],
|
|
167
|
-
serializedStats.errors?.[0]?.moduleName ?? ""
|
|
168
|
-
);
|
|
169
|
-
throw new Error(errorWithContext);
|
|
170
|
-
}
|
|
171
|
-
if (isCi && warnings.length) {
|
|
172
|
-
const warningsWithContext = warnings.map((warning, i) => {
|
|
173
|
-
return applyContextToError(
|
|
174
|
-
warning,
|
|
175
|
-
serializedStats.warnings?.[i]?.moduleName ?? ""
|
|
176
|
-
);
|
|
177
|
-
});
|
|
178
|
-
console.log(
|
|
179
|
-
chalk__default.default.yellow(
|
|
180
|
-
"\nTreating warnings as errors because process.env.CI = true.\n"
|
|
181
|
-
)
|
|
182
|
-
);
|
|
183
|
-
throw new Error(warningsWithContext.join("\n\n"));
|
|
184
|
-
}
|
|
185
|
-
return { stats };
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
exports.buildBundle = buildBundle;
|
|
189
|
-
//# sourceMappingURL=bundle.cjs.js.map
|
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('node:path');
|
|
4
|
-
var core = require('@rspack/core');
|
|
5
|
-
var ESLintRspackPlugin = require('eslint-rspack-plugin');
|
|
6
|
-
var tsCheckerRspackPlugin = require('ts-checker-rspack-plugin');
|
|
7
|
-
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
8
|
-
var ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
|
9
|
-
var rspack = require('@module-federation/enhanced/rspack');
|
|
10
|
-
var fs = require('fs-extra');
|
|
11
|
-
var optimization = require('./optimization.cjs.js');
|
|
12
|
-
var pickBy = require('lodash/pickBy');
|
|
13
|
-
var cliCommon = require('@backstage/cli-common');
|
|
14
|
-
var transforms = require('./transforms.cjs.js');
|
|
15
|
-
var version = require('../../../../wiring/version.cjs.js');
|
|
16
|
-
var yn = require('yn');
|
|
17
|
-
var hasReactDomClient = require('./hasReactDomClient.cjs.js');
|
|
18
|
-
var linkWorkspaces = require('./linkWorkspaces.cjs.js');
|
|
19
|
-
var ConfigInjectingHtmlWebpackPlugin = require('./ConfigInjectingHtmlWebpackPlugin.cjs.js');
|
|
20
|
-
|
|
21
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
22
|
-
|
|
23
|
-
var ESLintRspackPlugin__default = /*#__PURE__*/_interopDefaultCompat(ESLintRspackPlugin);
|
|
24
|
-
var HtmlWebpackPlugin__default = /*#__PURE__*/_interopDefaultCompat(HtmlWebpackPlugin);
|
|
25
|
-
var ModuleScopePlugin__default = /*#__PURE__*/_interopDefaultCompat(ModuleScopePlugin);
|
|
26
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
27
|
-
var pickBy__default = /*#__PURE__*/_interopDefaultCompat(pickBy);
|
|
28
|
-
var yn__default = /*#__PURE__*/_interopDefaultCompat(yn);
|
|
29
|
-
|
|
30
|
-
function resolveBaseUrl(config, moduleFederationRemote) {
|
|
31
|
-
const baseUrl = config.getOptionalString("app.baseUrl");
|
|
32
|
-
const defaultBaseUrl = moduleFederationRemote ? `http://localhost:${process.env.PORT ?? "3000"}` : "http://localhost:3000";
|
|
33
|
-
try {
|
|
34
|
-
return new URL(baseUrl ?? "/", defaultBaseUrl);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
throw new Error(`Invalid app.baseUrl, ${error}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function resolveEndpoint(config, moduleFederationRemote) {
|
|
40
|
-
const url = resolveBaseUrl(config, moduleFederationRemote);
|
|
41
|
-
return {
|
|
42
|
-
host: config.getOptionalString("app.listen.host") ?? url.hostname,
|
|
43
|
-
port: config.getOptionalNumber("app.listen.port") ?? Number(url.port) ?? (url.protocol === "https:" ? 443 : 80)
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
async function readBuildInfo() {
|
|
47
|
-
const timestamp = Date.now();
|
|
48
|
-
let commit;
|
|
49
|
-
try {
|
|
50
|
-
commit = await cliCommon.runOutput(["git", "rev-parse", "HEAD"]);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
}
|
|
53
|
-
let gitVersion;
|
|
54
|
-
try {
|
|
55
|
-
gitVersion = await cliCommon.runOutput(["git", "describe", "--always"]);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
}
|
|
58
|
-
if (commit === void 0 || gitVersion === void 0) {
|
|
59
|
-
console.info(
|
|
60
|
-
"NOTE: Did not compute git version or commit hash, could not execute the git command line utility"
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
const { version: packageVersion } = await fs__default.default.readJson(
|
|
64
|
-
cliCommon.targetPaths.resolve("package.json")
|
|
65
|
-
);
|
|
66
|
-
return {
|
|
67
|
-
cliVersion: version.version,
|
|
68
|
-
gitVersion: gitVersion ?? "unknown",
|
|
69
|
-
packageVersion,
|
|
70
|
-
timestamp,
|
|
71
|
-
commit: commit ?? "unknown"
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
async function createConfig(paths, options) {
|
|
75
|
-
const {
|
|
76
|
-
checksEnabled,
|
|
77
|
-
isDev,
|
|
78
|
-
frontendConfig,
|
|
79
|
-
moduleFederationRemote,
|
|
80
|
-
publicSubPath = "",
|
|
81
|
-
webpack
|
|
82
|
-
} = options;
|
|
83
|
-
const { plugins, loaders } = transforms.transforms(options);
|
|
84
|
-
const validBaseUrl = resolveBaseUrl(frontendConfig, moduleFederationRemote);
|
|
85
|
-
let publicPath = validBaseUrl.pathname.replace(/\/$/, "");
|
|
86
|
-
if (publicSubPath) {
|
|
87
|
-
publicPath = `${publicPath}${publicSubPath}`.replace("//", "/");
|
|
88
|
-
}
|
|
89
|
-
if (isDev) {
|
|
90
|
-
const { host, port } = resolveEndpoint(
|
|
91
|
-
options.frontendConfig,
|
|
92
|
-
options.moduleFederationRemote
|
|
93
|
-
);
|
|
94
|
-
const refreshOptions = {
|
|
95
|
-
overlay: {
|
|
96
|
-
sockProtocol: "ws",
|
|
97
|
-
sockHost: host,
|
|
98
|
-
sockPort: port
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
if (webpack) {
|
|
102
|
-
const ReactRefreshPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
|
103
|
-
plugins.push(new ReactRefreshPlugin(refreshOptions));
|
|
104
|
-
} else {
|
|
105
|
-
const RspackReactRefreshPlugin = require("@rspack/plugin-react-refresh");
|
|
106
|
-
plugins.push(new RspackReactRefreshPlugin(refreshOptions));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (checksEnabled) {
|
|
110
|
-
const TsCheckerPlugin = webpack ? require("fork-ts-checker-webpack-plugin") : tsCheckerRspackPlugin.TsCheckerRspackPlugin;
|
|
111
|
-
const ESLintPlugin = webpack ? require("eslint-webpack-plugin") : ESLintRspackPlugin__default.default;
|
|
112
|
-
plugins.push(
|
|
113
|
-
new TsCheckerPlugin({
|
|
114
|
-
typescript: { configFile: paths.targetTsConfig, memoryLimit: 8192 }
|
|
115
|
-
}),
|
|
116
|
-
new ESLintPlugin({
|
|
117
|
-
cache: false,
|
|
118
|
-
// Cache seems broken
|
|
119
|
-
context: paths.targetPath,
|
|
120
|
-
files: ["**/*.(ts|tsx|mts|cts|js|jsx|mjs|cjs)"]
|
|
121
|
-
})
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
const bundler = webpack ? webpack : core.rspack;
|
|
125
|
-
plugins.push(
|
|
126
|
-
new bundler.ProvidePlugin({
|
|
127
|
-
process: require.resolve("process/browser"),
|
|
128
|
-
Buffer: ["buffer", "Buffer"]
|
|
129
|
-
})
|
|
130
|
-
);
|
|
131
|
-
if (!options.moduleFederationRemote) {
|
|
132
|
-
const templateOptions = {
|
|
133
|
-
meta: {
|
|
134
|
-
"backstage-app-mode": options?.appMode ?? "public"
|
|
135
|
-
},
|
|
136
|
-
template: paths.targetHtml,
|
|
137
|
-
templateParameters: {
|
|
138
|
-
publicPath,
|
|
139
|
-
config: frontendConfig
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
if (webpack) {
|
|
143
|
-
plugins.push(new HtmlWebpackPlugin__default.default(templateOptions));
|
|
144
|
-
} else {
|
|
145
|
-
plugins.push(
|
|
146
|
-
new ConfigInjectingHtmlWebpackPlugin.ConfigInjectingHtmlWebpackPlugin(
|
|
147
|
-
templateOptions,
|
|
148
|
-
options.getFrontendAppConfigs
|
|
149
|
-
)
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
plugins.push(
|
|
153
|
-
new HtmlWebpackPlugin__default.default({
|
|
154
|
-
meta: {
|
|
155
|
-
"backstage-app-mode": options?.appMode ?? "public",
|
|
156
|
-
// This is added to be written in the later step, and finally read by the extra entry point
|
|
157
|
-
"backstage-public-path": "<%= publicPath %>/"
|
|
158
|
-
},
|
|
159
|
-
minify: false,
|
|
160
|
-
publicPath: "<%= publicPath %>",
|
|
161
|
-
filename: "index.html.tmpl",
|
|
162
|
-
template: `${require.resolve("raw-loader")}!${paths.targetHtml}`
|
|
163
|
-
})
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
if (options.moduleFederationRemote) {
|
|
167
|
-
const AdaptedModuleFederationPlugin = webpack ? require("@module-federation/enhanced/webpack").ModuleFederationPlugin : rspack.ModuleFederationPlugin;
|
|
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
|
-
)
|
|
172
|
-
) : {
|
|
173
|
-
".": paths.targetEntry
|
|
174
|
-
};
|
|
175
|
-
plugins.push(
|
|
176
|
-
new AdaptedModuleFederationPlugin({
|
|
177
|
-
filename: "remoteEntry.js",
|
|
178
|
-
exposes,
|
|
179
|
-
name: options.moduleFederationRemote.name,
|
|
180
|
-
runtime: false,
|
|
181
|
-
shared: options.moduleFederationRemote.sharedDependencies
|
|
182
|
-
})
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
const buildInfo = await readBuildInfo();
|
|
186
|
-
plugins.push(
|
|
187
|
-
webpack ? new webpack.DefinePlugin({
|
|
188
|
-
"process.env.BUILD_INFO": JSON.stringify(buildInfo),
|
|
189
|
-
"process.env.APP_CONFIG": webpack.DefinePlugin.runtimeValue(
|
|
190
|
-
() => JSON.stringify(options.getFrontendAppConfigs()),
|
|
191
|
-
true
|
|
192
|
-
),
|
|
193
|
-
// This allows for conditional imports of react-dom/client, since there's no way
|
|
194
|
-
// to check for presence of it in source code without module resolution errors.
|
|
195
|
-
"process.env.HAS_REACT_DOM_CLIENT": JSON.stringify(
|
|
196
|
-
hasReactDomClient.hasReactDomClient()
|
|
197
|
-
)
|
|
198
|
-
}) : new bundler.DefinePlugin({
|
|
199
|
-
"process.env.BUILD_INFO": JSON.stringify(buildInfo),
|
|
200
|
-
"process.env.APP_CONFIG": JSON.stringify([]),
|
|
201
|
-
// Inject via index.html instead
|
|
202
|
-
// This allows for conditional imports of react-dom/client, since there's no way
|
|
203
|
-
// to check for presence of it in source code without module resolution errors.
|
|
204
|
-
"process.env.HAS_REACT_DOM_CLIENT": JSON.stringify(
|
|
205
|
-
hasReactDomClient.hasReactDomClient()
|
|
206
|
-
)
|
|
207
|
-
})
|
|
208
|
-
);
|
|
209
|
-
if (options.linkedWorkspace) {
|
|
210
|
-
plugins.push(
|
|
211
|
-
...await linkWorkspaces.createWorkspaceLinkingPlugins(
|
|
212
|
-
bundler,
|
|
213
|
-
options.linkedWorkspace
|
|
214
|
-
)
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
const reactRefreshFiles = webpack ? [
|
|
218
|
-
require.resolve(
|
|
219
|
-
"@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js"
|
|
220
|
-
),
|
|
221
|
-
require.resolve(
|
|
222
|
-
"@pmmmwh/react-refresh-webpack-plugin/overlay/index.js"
|
|
223
|
-
),
|
|
224
|
-
require.resolve("react-refresh")
|
|
225
|
-
] : [];
|
|
226
|
-
const mode = isDev ? "development" : "production";
|
|
227
|
-
const optimization$1 = optimization.optimization(options);
|
|
228
|
-
return {
|
|
229
|
-
mode,
|
|
230
|
-
profile: false,
|
|
231
|
-
...isDev ? {
|
|
232
|
-
watchOptions: {
|
|
233
|
-
ignored: /node_modules\/(?!__backstage-autodetected-plugins__)/
|
|
234
|
-
}
|
|
235
|
-
} : {},
|
|
236
|
-
optimization: optimization$1,
|
|
237
|
-
bail: false,
|
|
238
|
-
performance: {
|
|
239
|
-
hints: false
|
|
240
|
-
// we check the gzip size instead
|
|
241
|
-
},
|
|
242
|
-
devtool: isDev ? "eval-cheap-module-source-map" : "source-map",
|
|
243
|
-
context: paths.targetPath,
|
|
244
|
-
entry: [
|
|
245
|
-
require.resolve("@backstage/cli/config/webpack-public-path"),
|
|
246
|
-
...options.additionalEntryPoints ?? [],
|
|
247
|
-
paths.targetEntry
|
|
248
|
-
],
|
|
249
|
-
resolve: {
|
|
250
|
-
extensions: [".ts", ".tsx", ".mjs", ".js", ".jsx", ".json", ".wasm"],
|
|
251
|
-
mainFields: ["browser", "module", "main"],
|
|
252
|
-
fallback: {
|
|
253
|
-
...pickBy__default.default(require("node-stdlib-browser")),
|
|
254
|
-
module: false,
|
|
255
|
-
dgram: false,
|
|
256
|
-
dns: false,
|
|
257
|
-
fs: false,
|
|
258
|
-
http2: false,
|
|
259
|
-
net: false,
|
|
260
|
-
tls: false,
|
|
261
|
-
child_process: false,
|
|
262
|
-
/* new ignores */
|
|
263
|
-
path: false,
|
|
264
|
-
https: false,
|
|
265
|
-
http: false,
|
|
266
|
-
util: require.resolve("util/")
|
|
267
|
-
},
|
|
268
|
-
// FIXME: see also https://github.com/web-infra-dev/rspack/issues/3408
|
|
269
|
-
...webpack && {
|
|
270
|
-
plugins: [
|
|
271
|
-
new ModuleScopePlugin__default.default(
|
|
272
|
-
[paths.targetSrc, paths.targetDev],
|
|
273
|
-
[paths.targetPackageJson, ...reactRefreshFiles]
|
|
274
|
-
)
|
|
275
|
-
]
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
module: {
|
|
279
|
-
rules: loaders
|
|
280
|
-
},
|
|
281
|
-
output: {
|
|
282
|
-
uniqueName: options.moduleFederationRemote?.name,
|
|
283
|
-
path: paths.targetDist,
|
|
284
|
-
publicPath: options.moduleFederationRemote ? "auto" : `${publicPath}/`,
|
|
285
|
-
filename: isDev ? "[name].js" : "static/[name].[contenthash:8].js",
|
|
286
|
-
chunkFilename: isDev ? "[name].chunk.js" : "static/[name].[contenthash:8].chunk.js",
|
|
287
|
-
...isDev ? {
|
|
288
|
-
devtoolModuleFilenameTemplate: (info) => `file:///${path.resolve(info.absoluteResourcePath).replace(
|
|
289
|
-
/\\/g,
|
|
290
|
-
"/"
|
|
291
|
-
)}`
|
|
292
|
-
} : {}
|
|
293
|
-
},
|
|
294
|
-
experiments: {
|
|
295
|
-
lazyCompilation: yn__default.default(process.env.EXPERIMENTAL_LAZY_COMPILATION),
|
|
296
|
-
...!webpack && {
|
|
297
|
-
// We're still using `style-loader` for custom `insert` option
|
|
298
|
-
css: false
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
|
-
plugins
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
exports.createConfig = createConfig;
|
|
306
|
-
exports.resolveBaseUrl = resolveBaseUrl;
|
|
307
|
-
exports.resolveEndpoint = resolveEndpoint;
|
|
308
|
-
//# sourceMappingURL=config.cjs.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var cliCommon = require('@backstage/cli-common');
|
|
4
|
-
|
|
5
|
-
function hasReactDomClient() {
|
|
6
|
-
try {
|
|
7
|
-
require.resolve("react-dom/client", {
|
|
8
|
-
paths: [cliCommon.targetPaths.dir]
|
|
9
|
-
});
|
|
10
|
-
return true;
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
exports.hasReactDomClient = hasReactDomClient;
|
|
17
|
-
//# sourceMappingURL=hasReactDomClient.cjs.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('node:path');
|
|
4
|
-
var getPackages = require('@manypkg/get-packages');
|
|
5
|
-
var cliCommon = require('@backstage/cli-common');
|
|
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(
|
|
23
|
-
/^react(?:-router)?(?:-dom)?$/,
|
|
24
|
-
(resource) => {
|
|
25
|
-
if (!path.relative(linkedRoot.dir, resource.context).startsWith("..")) {
|
|
26
|
-
resource.context = cliCommon.targetPaths.dir;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
)
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports.createWorkspaceLinkingPlugins = createWorkspaceLinkingPlugins;
|
|
34
|
-
//# sourceMappingURL=linkWorkspaces.cjs.js.map
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var entryPoints = require('../entryPoints.cjs.js');
|
|
4
|
-
var typeDistProject = require('../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');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
14
|
-
var chokidar__default = /*#__PURE__*/_interopDefaultCompat(chokidar);
|
|
15
|
-
var PQueue__default = /*#__PURE__*/_interopDefaultCompat(PQueue);
|
|
16
|
-
|
|
17
|
-
async function getModuleFederationRemoteOptions(packageJson, packageDir) {
|
|
18
|
-
let exposes;
|
|
19
|
-
const packageRole = packageJson.backstage?.role;
|
|
20
|
-
if (packageJson.exports && packageRole) {
|
|
21
|
-
const project = await typeDistProject.createTypeDistProject();
|
|
22
|
-
exposes = Object.fromEntries(
|
|
23
|
-
entryPoints.readEntryPoints(packageJson).filter((ep) => {
|
|
24
|
-
if (ep.mount === "./package.json") {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
if (ep.mount === ".") {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return typeDistProject.getEntryPointDefaultFeatureType(
|
|
31
|
-
packageRole,
|
|
32
|
-
packageDir,
|
|
33
|
-
project,
|
|
34
|
-
ep.path
|
|
35
|
-
) !== null;
|
|
36
|
-
}).map((ep) => [ep.mount, ep.path])
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
// The default output mode requires the name to be a usable as a code
|
|
41
|
-
// symbol, there might be better options here but for now we need to
|
|
42
|
-
// sanitize the name.
|
|
43
|
-
name: packageJson.name.replaceAll("@", "").replaceAll("/", "__").replaceAll("-", "_"),
|
|
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
|
-
);
|
|
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];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
exports.createRuntimeSharedDependenciesEntryPoint = createRuntimeSharedDependenciesEntryPoint;
|
|
133
|
-
exports.getModuleFederationRemoteOptions = getModuleFederationRemoteOptions;
|
|
134
|
-
exports.prepareRuntimeSharedDependenciesScript = prepareRuntimeSharedDependenciesScript;
|
|
135
|
-
//# sourceMappingURL=moduleFederation.cjs.js.map
|