@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,81 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var os = require('node:os');
|
|
4
|
-
var fs = require('fs-extra');
|
|
5
|
-
var path = require('node:path');
|
|
6
|
-
var tar = require('tar');
|
|
7
|
-
var createDistWorkspace = require('./packager/createDistWorkspace.cjs.js');
|
|
8
|
-
var packager = require('./builder/packager.cjs.js');
|
|
9
|
-
var types = require('./builder/types.cjs.js');
|
|
10
|
-
var cliNode = require('@backstage/cli-node');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
-
|
|
14
|
-
function _interopNamespaceCompat(e) {
|
|
15
|
-
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
16
|
-
var n = Object.create(null);
|
|
17
|
-
if (e) {
|
|
18
|
-
Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !== 'default') {
|
|
20
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return e[k]; }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
n.default = e;
|
|
29
|
-
return Object.freeze(n);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var os__default = /*#__PURE__*/_interopDefaultCompat(os);
|
|
33
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
34
|
-
var tar__namespace = /*#__PURE__*/_interopNamespaceCompat(tar);
|
|
35
|
-
|
|
36
|
-
const BUNDLE_FILE = "bundle.tar.gz";
|
|
37
|
-
const SKELETON_FILE = "skeleton.tar.gz";
|
|
38
|
-
async function buildBackend(options) {
|
|
39
|
-
const { targetDir, skipBuildDependencies, configPaths, minify } = options;
|
|
40
|
-
const pkg = await fs__default.default.readJson(path.resolve(targetDir, "package.json"));
|
|
41
|
-
await packager.buildPackage({
|
|
42
|
-
targetDir,
|
|
43
|
-
packageJson: pkg,
|
|
44
|
-
outputs: /* @__PURE__ */ new Set([types.Output.cjs]),
|
|
45
|
-
minify,
|
|
46
|
-
workspacePackages: await cliNode.PackageGraph.listTargetPackages()
|
|
47
|
-
});
|
|
48
|
-
const tmpDir = await fs__default.default.mkdtemp(path.resolve(os__default.default.tmpdir(), "backstage-bundle"));
|
|
49
|
-
try {
|
|
50
|
-
await createDistWorkspace.createDistWorkspace([pkg.name], {
|
|
51
|
-
targetDir: tmpDir,
|
|
52
|
-
configPaths,
|
|
53
|
-
buildDependencies: !skipBuildDependencies,
|
|
54
|
-
buildExcludes: [pkg.name],
|
|
55
|
-
skeleton: SKELETON_FILE,
|
|
56
|
-
minify
|
|
57
|
-
});
|
|
58
|
-
const distDir = path.resolve(targetDir, "dist");
|
|
59
|
-
await fs__default.default.remove(distDir);
|
|
60
|
-
await fs__default.default.mkdir(distDir);
|
|
61
|
-
await fs__default.default.move(
|
|
62
|
-
path.resolve(tmpDir, SKELETON_FILE),
|
|
63
|
-
path.resolve(distDir, SKELETON_FILE)
|
|
64
|
-
);
|
|
65
|
-
await tar__namespace.create(
|
|
66
|
-
{
|
|
67
|
-
file: path.resolve(distDir, BUNDLE_FILE),
|
|
68
|
-
cwd: tmpDir,
|
|
69
|
-
portable: true,
|
|
70
|
-
noMtime: true,
|
|
71
|
-
gzip: true
|
|
72
|
-
},
|
|
73
|
-
[""]
|
|
74
|
-
);
|
|
75
|
-
} finally {
|
|
76
|
-
await fs__default.default.remove(tmpDir);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
exports.buildBackend = buildBackend;
|
|
81
|
-
//# sourceMappingURL=buildBackend.cjs.js.map
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs-extra');
|
|
4
|
-
var path = require('node:path');
|
|
5
|
-
var bundle = require('./bundler/bundle.cjs.js');
|
|
6
|
-
var moduleFederation = require('./bundler/moduleFederation.cjs.js');
|
|
7
|
-
require('chalk');
|
|
8
|
-
require('react-dev-utils/openBrowser');
|
|
9
|
-
require('@rspack/core');
|
|
10
|
-
require('@rspack/dev-server');
|
|
11
|
-
require('@backstage/cli-common');
|
|
12
|
-
var config = require('./config.cjs.js');
|
|
13
|
-
require('eslint-rspack-plugin');
|
|
14
|
-
require('ts-checker-rspack-plugin');
|
|
15
|
-
require('html-webpack-plugin');
|
|
16
|
-
require('react-dev-utils/ModuleScopePlugin');
|
|
17
|
-
require('@module-federation/enhanced/rspack');
|
|
18
|
-
require('lodash/pickBy');
|
|
19
|
-
require('../../../wiring/version.cjs.js');
|
|
20
|
-
require('yn');
|
|
21
|
-
require('@manypkg/get-packages');
|
|
22
|
-
require('./bundler/packageDetection.cjs.js');
|
|
23
|
-
|
|
24
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
25
|
-
|
|
26
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
27
|
-
|
|
28
|
-
async function buildFrontend(options) {
|
|
29
|
-
const { targetDir, writeStats, configPaths, webpack } = options;
|
|
30
|
-
const packageJson = await fs__default.default.readJson(
|
|
31
|
-
path.resolve(targetDir, "package.json")
|
|
32
|
-
);
|
|
33
|
-
await bundle.buildBundle({
|
|
34
|
-
targetDir,
|
|
35
|
-
entry: "src/index",
|
|
36
|
-
statsJsonEnabled: writeStats,
|
|
37
|
-
moduleFederationRemote: options.isModuleFederationRemote ? await moduleFederation.getModuleFederationRemoteOptions(
|
|
38
|
-
packageJson,
|
|
39
|
-
path.resolve(targetDir)
|
|
40
|
-
) : void 0,
|
|
41
|
-
...await config.loadCliConfig({
|
|
42
|
-
args: configPaths,
|
|
43
|
-
fromPackage: packageJson.name
|
|
44
|
-
}),
|
|
45
|
-
webpack
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
exports.buildFrontend = buildFrontend;
|
|
50
|
-
//# sourceMappingURL=buildFrontend.cjs.js.map
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chalk = require('chalk');
|
|
4
|
-
var fs = require('fs-extra');
|
|
5
|
-
var crypto = require('node:crypto');
|
|
6
|
-
var path = require('node:path');
|
|
7
|
-
var commonjs = require('@rollup/plugin-commonjs');
|
|
8
|
-
var resolve = require('@rollup/plugin-node-resolve');
|
|
9
|
-
var postcss = require('rollup-plugin-postcss');
|
|
10
|
-
var esbuild = require('rollup-plugin-esbuild');
|
|
11
|
-
var dts = require('rollup-plugin-dts');
|
|
12
|
-
var json = require('@rollup/plugin-json');
|
|
13
|
-
var yaml = require('@rollup/plugin-yaml');
|
|
14
|
-
var plugins = require('./plugins.cjs.js');
|
|
15
|
-
var types = require('./types.cjs.js');
|
|
16
|
-
var cliCommon = require('@backstage/cli-common');
|
|
17
|
-
var entryPoints = require('../entryPoints.cjs.js');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
20
|
-
|
|
21
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
22
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
23
|
-
var commonjs__default = /*#__PURE__*/_interopDefaultCompat(commonjs);
|
|
24
|
-
var resolve__default = /*#__PURE__*/_interopDefaultCompat(resolve);
|
|
25
|
-
var postcss__default = /*#__PURE__*/_interopDefaultCompat(postcss);
|
|
26
|
-
var esbuild__default = /*#__PURE__*/_interopDefaultCompat(esbuild);
|
|
27
|
-
var dts__default = /*#__PURE__*/_interopDefaultCompat(dts);
|
|
28
|
-
var json__default = /*#__PURE__*/_interopDefaultCompat(json);
|
|
29
|
-
var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
30
|
-
|
|
31
|
-
const SCRIPT_EXTS = [".js", ".jsx", ".ts", ".tsx"];
|
|
32
|
-
const MODULE_EXTS = [".mjs", ".mts"];
|
|
33
|
-
const COMMONJS_EXTS = [".cjs", ".cts"];
|
|
34
|
-
const MOD_EXT = ".mjs";
|
|
35
|
-
const CJS_EXT = ".cjs";
|
|
36
|
-
const CJS_JS_EXT = ".cjs.js";
|
|
37
|
-
function isFileImport(source) {
|
|
38
|
-
if (source.startsWith(".")) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
if (source.startsWith("/")) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
if (source.match(/[a-z]:/i)) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
function buildInternalImportPattern(options) {
|
|
50
|
-
const inlinedPackages = options.workspacePackages.filter(
|
|
51
|
-
(pkg) => pkg.packageJson.backstage?.inline
|
|
52
|
-
);
|
|
53
|
-
for (const { packageJson } of inlinedPackages) {
|
|
54
|
-
if (!packageJson.private) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`Inlined package ${packageJson.name} must be marked as private`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const names = inlinedPackages.map((pkg) => pkg.packageJson.name);
|
|
61
|
-
return new RegExp(`^(?:${names.join("|")})(?:$|/)`);
|
|
62
|
-
}
|
|
63
|
-
function multiOutputFormat() {
|
|
64
|
-
return {
|
|
65
|
-
name: "backstage-multi-output-format",
|
|
66
|
-
generateBundle(opts, bundle) {
|
|
67
|
-
const filter = opts.format === "cjs" ? (s) => s.endsWith(MOD_EXT) : (s) => !s.endsWith(MOD_EXT);
|
|
68
|
-
for (const name in bundle) {
|
|
69
|
-
if (filter(name)) {
|
|
70
|
-
delete bundle[name];
|
|
71
|
-
delete bundle[`${name}.map`];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
renderDynamicImport(opts) {
|
|
76
|
-
if (opts.format === "cjs") {
|
|
77
|
-
return {
|
|
78
|
-
left: "import(",
|
|
79
|
-
right: ")"
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return void 0;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
async function makeRollupConfigs(options) {
|
|
87
|
-
const configs = new Array();
|
|
88
|
-
const targetDir = options.targetDir ?? cliCommon.targetPaths.dir;
|
|
89
|
-
let targetPkg = options.packageJson;
|
|
90
|
-
if (!targetPkg) {
|
|
91
|
-
const packagePath = path.resolve(targetDir, "package.json");
|
|
92
|
-
targetPkg = await fs__default.default.readJson(packagePath);
|
|
93
|
-
}
|
|
94
|
-
const onwarn = ({ code, message }) => {
|
|
95
|
-
if (code === "EMPTY_BUNDLE") {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (options.logPrefix) {
|
|
99
|
-
console.log(options.logPrefix + message);
|
|
100
|
-
} else {
|
|
101
|
-
console.log(message);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
const distDir = path.resolve(targetDir, "dist");
|
|
105
|
-
const entryPoints$1 = entryPoints.readEntryPoints(targetPkg);
|
|
106
|
-
const scriptEntryPoints = entryPoints$1.filter(
|
|
107
|
-
(e) => SCRIPT_EXTS.includes(e.ext)
|
|
108
|
-
);
|
|
109
|
-
const internalImportPattern = buildInternalImportPattern(options);
|
|
110
|
-
const external = (source, importer, isResolved) => Boolean(
|
|
111
|
-
importer && !isResolved && !internalImportPattern.test(source) && !isFileImport(source)
|
|
112
|
-
);
|
|
113
|
-
if (options.outputs.has(types.Output.cjs) || options.outputs.has(types.Output.esm)) {
|
|
114
|
-
const output = new Array();
|
|
115
|
-
const mainFields = ["module", "main"];
|
|
116
|
-
const rewriteNodeModules = (name) => name.replaceAll("node_modules", "node_modules_dist");
|
|
117
|
-
if (options.outputs.has(types.Output.cjs)) {
|
|
118
|
-
const defaultExt = targetPkg.type === "module" ? MOD_EXT : CJS_JS_EXT;
|
|
119
|
-
const outputOpts = {
|
|
120
|
-
dir: distDir,
|
|
121
|
-
entryFileNames(chunkInfo) {
|
|
122
|
-
const cleanName = rewriteNodeModules(chunkInfo.name);
|
|
123
|
-
const inputId = chunkInfo.facadeModuleId;
|
|
124
|
-
if (!inputId) {
|
|
125
|
-
return cleanName + defaultExt;
|
|
126
|
-
}
|
|
127
|
-
const inputExt = path.extname(inputId);
|
|
128
|
-
if (MODULE_EXTS.includes(inputExt)) {
|
|
129
|
-
return cleanName + MOD_EXT;
|
|
130
|
-
}
|
|
131
|
-
if (COMMONJS_EXTS.includes(inputExt)) {
|
|
132
|
-
return cleanName + CJS_EXT;
|
|
133
|
-
}
|
|
134
|
-
return cleanName + defaultExt;
|
|
135
|
-
},
|
|
136
|
-
sourcemap: true,
|
|
137
|
-
preserveModules: true,
|
|
138
|
-
preserveModulesRoot: `${targetDir}/src`,
|
|
139
|
-
interop: "compat",
|
|
140
|
-
exports: "named",
|
|
141
|
-
plugins: [multiOutputFormat()]
|
|
142
|
-
};
|
|
143
|
-
output.push({
|
|
144
|
-
...outputOpts,
|
|
145
|
-
format: "cjs"
|
|
146
|
-
});
|
|
147
|
-
output.push({
|
|
148
|
-
...outputOpts,
|
|
149
|
-
format: "module"
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
if (options.outputs.has(types.Output.esm)) {
|
|
153
|
-
output.push({
|
|
154
|
-
dir: distDir,
|
|
155
|
-
entryFileNames: (chunkInfo) => `${rewriteNodeModules(chunkInfo.name)}.esm.js`,
|
|
156
|
-
chunkFileNames: `esm/[name]-[hash].esm.js`,
|
|
157
|
-
format: "module",
|
|
158
|
-
sourcemap: true,
|
|
159
|
-
preserveModules: true,
|
|
160
|
-
preserveModulesRoot: `${targetDir}/src`
|
|
161
|
-
});
|
|
162
|
-
mainFields.unshift("browser");
|
|
163
|
-
}
|
|
164
|
-
configs.push({
|
|
165
|
-
input: Object.fromEntries(
|
|
166
|
-
scriptEntryPoints.map((e) => [e.name, path.resolve(targetDir, e.path)])
|
|
167
|
-
),
|
|
168
|
-
output,
|
|
169
|
-
onwarn,
|
|
170
|
-
makeAbsoluteExternalsRelative: false,
|
|
171
|
-
preserveEntrySignatures: "strict",
|
|
172
|
-
// All module imports are always marked as external
|
|
173
|
-
external,
|
|
174
|
-
plugins: [
|
|
175
|
-
resolve__default.default({
|
|
176
|
-
mainFields,
|
|
177
|
-
extensions: SCRIPT_EXTS
|
|
178
|
-
}),
|
|
179
|
-
commonjs__default.default({
|
|
180
|
-
include: /node_modules/,
|
|
181
|
-
exclude: [/\/[^/]+\.(?:stories|test)\.[^/]+$/]
|
|
182
|
-
}),
|
|
183
|
-
postcss__default.default({
|
|
184
|
-
modules: {
|
|
185
|
-
generateScopedName(name, filename, css) {
|
|
186
|
-
const hash = crypto.createHash("md5").update(css).digest("hex").slice(0, 10);
|
|
187
|
-
const file = path.basename(filename, ".module.css");
|
|
188
|
-
return `${file}_${name}__${hash}`;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}),
|
|
192
|
-
plugins.forwardFileImports({
|
|
193
|
-
exclude: /\.icon\.svg$/,
|
|
194
|
-
include: [
|
|
195
|
-
/\.svg$/,
|
|
196
|
-
/\.png$/,
|
|
197
|
-
/\.gif$/,
|
|
198
|
-
/\.jpg$/,
|
|
199
|
-
/\.jpeg$/,
|
|
200
|
-
/\.webp$/,
|
|
201
|
-
/\.eot$/,
|
|
202
|
-
/\.woff$/,
|
|
203
|
-
/\.woff2$/,
|
|
204
|
-
/\.ttf$/,
|
|
205
|
-
/\.md$/
|
|
206
|
-
]
|
|
207
|
-
}),
|
|
208
|
-
json__default.default(),
|
|
209
|
-
yaml__default.default(),
|
|
210
|
-
esbuild__default.default({
|
|
211
|
-
target: "ES2023",
|
|
212
|
-
minify: options.minify
|
|
213
|
-
}),
|
|
214
|
-
plugins.cssEntryPoints({ entryPoints: entryPoints$1, targetDir })
|
|
215
|
-
]
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
if (options.outputs.has(types.Output.types)) {
|
|
219
|
-
const input = Object.fromEntries(
|
|
220
|
-
scriptEntryPoints.map((e) => [
|
|
221
|
-
e.name,
|
|
222
|
-
cliCommon.targetPaths.resolveRoot(
|
|
223
|
-
"dist-types",
|
|
224
|
-
path.relative(cliCommon.targetPaths.rootDir, targetDir),
|
|
225
|
-
e.path.replace(/\.(?:ts|tsx)$/, ".d.ts")
|
|
226
|
-
)
|
|
227
|
-
])
|
|
228
|
-
);
|
|
229
|
-
for (const path$1 of Object.values(input)) {
|
|
230
|
-
const declarationsExist = await fs__default.default.pathExists(path$1);
|
|
231
|
-
if (!declarationsExist) {
|
|
232
|
-
const declarationPath = path.relative(targetDir, path$1);
|
|
233
|
-
throw new Error(
|
|
234
|
-
`No declaration files found at ${declarationPath}, be sure to run ${chalk__default.default.bgRed.white(
|
|
235
|
-
"yarn tsc"
|
|
236
|
-
)} to generate .d.ts files before packaging`
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
configs.push({
|
|
241
|
-
input,
|
|
242
|
-
output: {
|
|
243
|
-
dir: distDir,
|
|
244
|
-
entryFileNames: `[name].d.ts`,
|
|
245
|
-
chunkFileNames: `types/[name]-[hash].d.ts`,
|
|
246
|
-
format: "es"
|
|
247
|
-
},
|
|
248
|
-
external: (source, importer, isResolved) => /\.css|scss|sass|svg|eot|woff|woff2|ttf$/.test(source) || external(source, importer, isResolved),
|
|
249
|
-
onwarn,
|
|
250
|
-
plugins: [dts__default.default({ respectExternal: true })]
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
return configs;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
exports.makeRollupConfigs = makeRollupConfigs;
|
|
257
|
-
//# sourceMappingURL=config.cjs.js.map
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs-extra');
|
|
4
|
-
var rollup = require('rollup');
|
|
5
|
-
var chalk = require('chalk');
|
|
6
|
-
var path = require('node:path');
|
|
7
|
-
var cliCommon = require('@backstage/cli-common');
|
|
8
|
-
var config = require('./config.cjs.js');
|
|
9
|
-
var types = require('./types.cjs.js');
|
|
10
|
-
var cliNode = require('@backstage/cli-node');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
-
|
|
14
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
15
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
16
|
-
|
|
17
|
-
function formatErrorMessage(error) {
|
|
18
|
-
let msg = "";
|
|
19
|
-
if (error.code === "PLUGIN_ERROR") {
|
|
20
|
-
if (error.plugin === "esbuild") {
|
|
21
|
-
msg += `${error.message}`;
|
|
22
|
-
if (error.errors?.length) {
|
|
23
|
-
msg += `
|
|
24
|
-
|
|
25
|
-
`;
|
|
26
|
-
for (const { text, location } of error.errors) {
|
|
27
|
-
const { line, column } = location;
|
|
28
|
-
const path$1 = path.relative(cliCommon.targetPaths.dir, error.id);
|
|
29
|
-
const loc = chalk__default.default.cyan(`${path$1}:${line}:${column}`);
|
|
30
|
-
if (text === 'Unexpected "<"' && error.id.endsWith(".js")) {
|
|
31
|
-
msg += `${loc}: ${text}, JavaScript files with JSX should use a .jsx extension`;
|
|
32
|
-
} else {
|
|
33
|
-
msg += `${loc}: ${text}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
msg += `(plugin ${error.plugin}) ${error}
|
|
39
|
-
`;
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
if (error.loc) {
|
|
43
|
-
const file = `${cliCommon.targetPaths.resolve(error.loc.file || error.id)}`;
|
|
44
|
-
const pos = `${error.loc.line}:${error.loc.column}`;
|
|
45
|
-
msg += `${file} [${pos}]
|
|
46
|
-
`;
|
|
47
|
-
} else if (error.id) {
|
|
48
|
-
msg += `${cliCommon.targetPaths.resolve(error.id)}
|
|
49
|
-
`;
|
|
50
|
-
}
|
|
51
|
-
msg += `${error}
|
|
52
|
-
`;
|
|
53
|
-
if (error.url) {
|
|
54
|
-
msg += `${chalk__default.default.cyan(error.url)}
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
if (error.frame) {
|
|
58
|
-
msg += `${chalk__default.default.dim(error.frame)}
|
|
59
|
-
`;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return msg;
|
|
63
|
-
}
|
|
64
|
-
async function rollupBuild(config) {
|
|
65
|
-
try {
|
|
66
|
-
const bundle = await rollup.rollup(config);
|
|
67
|
-
if (config.output) {
|
|
68
|
-
for (const output of [config.output].flat()) {
|
|
69
|
-
await bundle.generate(output);
|
|
70
|
-
await bundle.write(output);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} catch (error) {
|
|
74
|
-
throw new Error(formatErrorMessage(error));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const buildPackage = async (options) => {
|
|
78
|
-
try {
|
|
79
|
-
const { resolutions } = await fs__default.default.readJson(
|
|
80
|
-
cliCommon.targetPaths.resolveRoot("package.json")
|
|
81
|
-
);
|
|
82
|
-
if (resolutions?.esbuild) {
|
|
83
|
-
console.warn(
|
|
84
|
-
chalk__default.default.red(
|
|
85
|
-
'Your root package.json contains a "resolutions" entry for "esbuild". This was included in older @backstage/create-app templates in order to work around build issues that have since been fixed. Please remove the entry and run `yarn install`'
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
} catch {
|
|
90
|
-
}
|
|
91
|
-
const rollupConfigs = await config.makeRollupConfigs(options);
|
|
92
|
-
const targetDir = options.targetDir ?? cliCommon.targetPaths.dir;
|
|
93
|
-
await fs__default.default.remove(path.resolve(targetDir, "dist"));
|
|
94
|
-
const buildTasks = rollupConfigs.map(rollupBuild);
|
|
95
|
-
await Promise.all(buildTasks);
|
|
96
|
-
};
|
|
97
|
-
const buildPackages = async (options) => {
|
|
98
|
-
if (options.some((opt) => !opt.targetDir)) {
|
|
99
|
-
throw new Error("targetDir must be set for all build options");
|
|
100
|
-
}
|
|
101
|
-
const rollupConfigs = await Promise.all(options.map(config.makeRollupConfigs));
|
|
102
|
-
await Promise.all(
|
|
103
|
-
options.map(({ targetDir }) => fs__default.default.remove(path.resolve(targetDir, "dist")))
|
|
104
|
-
);
|
|
105
|
-
const buildTasks = rollupConfigs.flat().map((opts) => () => rollupBuild(opts));
|
|
106
|
-
await cliNode.runConcurrentTasks({
|
|
107
|
-
items: buildTasks,
|
|
108
|
-
worker: async (task) => task()
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
function getOutputsForRole(role) {
|
|
112
|
-
const outputs = /* @__PURE__ */ new Set();
|
|
113
|
-
for (const output of cliNode.PackageRoles.getRoleInfo(role).output) {
|
|
114
|
-
if (output === "cjs") {
|
|
115
|
-
outputs.add(types.Output.cjs);
|
|
116
|
-
}
|
|
117
|
-
if (output === "esm") {
|
|
118
|
-
outputs.add(types.Output.esm);
|
|
119
|
-
}
|
|
120
|
-
if (output === "types") {
|
|
121
|
-
outputs.add(types.Output.types);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return outputs;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
exports.buildPackage = buildPackage;
|
|
128
|
-
exports.buildPackages = buildPackages;
|
|
129
|
-
exports.formatErrorMessage = formatErrorMessage;
|
|
130
|
-
exports.getOutputsForRole = getOutputsForRole;
|
|
131
|
-
//# sourceMappingURL=packager.cjs.js.map
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs-extra');
|
|
4
|
-
var postcss = require('postcss');
|
|
5
|
-
var postcssImport = require('postcss-import');
|
|
6
|
-
var path = require('node:path');
|
|
7
|
-
var rollupPluginutils = require('rollup-pluginutils');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
|
-
|
|
11
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
12
|
-
var postcss__default = /*#__PURE__*/_interopDefaultCompat(postcss);
|
|
13
|
-
var postcssImport__default = /*#__PURE__*/_interopDefaultCompat(postcssImport);
|
|
14
|
-
|
|
15
|
-
function forwardFileImports(options) {
|
|
16
|
-
const filter = rollupPluginutils.createFilter(options.include, options.exclude);
|
|
17
|
-
const exportedFiles = /* @__PURE__ */ new Set();
|
|
18
|
-
const generatedFor = /* @__PURE__ */ new Set();
|
|
19
|
-
return {
|
|
20
|
-
name: "forward-file-imports",
|
|
21
|
-
async generateBundle(outputOptions, bundle, isWrite) {
|
|
22
|
-
if (!isWrite) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const dir = outputOptions.dir || path.dirname(outputOptions.file);
|
|
26
|
-
if (generatedFor.has(dir)) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
for (const output of Object.values(bundle)) {
|
|
30
|
-
if (output.type !== "chunk") {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
const chunk = output;
|
|
34
|
-
if (!chunk.facadeModuleId) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
generatedFor.add(dir);
|
|
38
|
-
const srcRoot = path.dirname(chunk.facadeModuleId);
|
|
39
|
-
await Promise.all(
|
|
40
|
-
Array.from(exportedFiles).map(async (exportedFile) => {
|
|
41
|
-
const outputPath = path.relative(srcRoot, exportedFile);
|
|
42
|
-
const targetFile = path.resolve(dir, outputPath);
|
|
43
|
-
await fs__default.default.ensureDir(path.dirname(targetFile));
|
|
44
|
-
await fs__default.default.copyFile(exportedFile, targetFile);
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
options(inputOptions) {
|
|
51
|
-
const treeshake = inputOptions.treeshake;
|
|
52
|
-
if (treeshake !== void 0 && typeof treeshake !== "object") {
|
|
53
|
-
throw new Error(
|
|
54
|
-
"Expected treeshake input config to be an object or not set"
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (treeshake?.moduleSideEffects) {
|
|
58
|
-
throw new Error("treeshake.moduleSideEffects must not be set");
|
|
59
|
-
}
|
|
60
|
-
const moduleSideEffects = (id) => {
|
|
61
|
-
if (filter(id)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
};
|
|
66
|
-
const origExternal = inputOptions.external;
|
|
67
|
-
const external = (id, importer, isResolved) => {
|
|
68
|
-
if (typeof origExternal === "function" && origExternal(id, importer, isResolved)) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
if (Array.isArray(origExternal) && origExternal.includes(id)) {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
if (!filter(id)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
if (!importer) {
|
|
78
|
-
throw new Error(`Unknown importer of file module ${id}`);
|
|
79
|
-
}
|
|
80
|
-
const fullId = isResolved ? id : path.resolve(path.dirname(importer), id);
|
|
81
|
-
exportedFiles.add(fullId);
|
|
82
|
-
return true;
|
|
83
|
-
};
|
|
84
|
-
return {
|
|
85
|
-
...inputOptions,
|
|
86
|
-
external,
|
|
87
|
-
treeshake: { ...treeshake, moduleSideEffects }
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function cssEntryPoints(options) {
|
|
93
|
-
const cssEntries = options.entryPoints.filter((ep) => ep.ext === ".css");
|
|
94
|
-
const generatedFor = /* @__PURE__ */ new Set();
|
|
95
|
-
return {
|
|
96
|
-
name: "backstage-css-entry-points",
|
|
97
|
-
async generateBundle(outputOptions, _bundle, isWrite) {
|
|
98
|
-
if (!isWrite) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const dir = outputOptions.dir || path.dirname(outputOptions.file);
|
|
102
|
-
if (generatedFor.has(dir)) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
generatedFor.add(dir);
|
|
106
|
-
for (const entryPoint of cssEntries) {
|
|
107
|
-
const sourcePath = path.resolve(options.targetDir, entryPoint.path);
|
|
108
|
-
const outputPath = entryPoint.path.replace(/^(\.\/)?src\//, "");
|
|
109
|
-
const source = await fs__default.default.readFile(sourcePath, "utf8");
|
|
110
|
-
const result = await postcss__default.default([postcssImport__default.default()]).process(source, {
|
|
111
|
-
from: sourcePath
|
|
112
|
-
});
|
|
113
|
-
this.emitFile({
|
|
114
|
-
type: "asset",
|
|
115
|
-
fileName: outputPath,
|
|
116
|
-
source: result.css
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
exports.cssEntryPoints = cssEntryPoints;
|
|
124
|
-
exports.forwardFileImports = forwardFileImports;
|
|
125
|
-
//# sourceMappingURL=plugins.cjs.js.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
|
-
|
|
5
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
6
|
-
|
|
7
|
-
var HtmlWebpackPlugin__default = /*#__PURE__*/_interopDefaultCompat(HtmlWebpackPlugin);
|
|
8
|
-
|
|
9
|
-
class ConfigInjectingHtmlWebpackPlugin extends HtmlWebpackPlugin__default.default {
|
|
10
|
-
name = "ConfigInjectingHtmlWebpackPlugin";
|
|
11
|
-
#getFrontendAppConfigs;
|
|
12
|
-
constructor(options, getFrontendAppConfigs) {
|
|
13
|
-
super(options);
|
|
14
|
-
this.#getFrontendAppConfigs = getFrontendAppConfigs;
|
|
15
|
-
}
|
|
16
|
-
apply = (compiler) => {
|
|
17
|
-
super.apply(compiler);
|
|
18
|
-
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
19
|
-
const hooks = HtmlWebpackPlugin__default.default.getCompilationHooks(compilation);
|
|
20
|
-
hooks.alterAssetTagGroups.tap(this.name, (ctx) => {
|
|
21
|
-
if (ctx.plugin !== this) {
|
|
22
|
-
return ctx;
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
...ctx,
|
|
26
|
-
headTags: [
|
|
27
|
-
...ctx.headTags,
|
|
28
|
-
HtmlWebpackPlugin__default.default.createHtmlTagObject(
|
|
29
|
-
"script",
|
|
30
|
-
{ type: "backstage.io/config" },
|
|
31
|
-
`
|
|
32
|
-
${JSON.stringify(this.#getFrontendAppConfigs(), null, 2)}
|
|
33
|
-
`
|
|
34
|
-
)
|
|
35
|
-
]
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.ConfigInjectingHtmlWebpackPlugin = ConfigInjectingHtmlWebpackPlugin;
|
|
43
|
-
//# sourceMappingURL=ConfigInjectingHtmlWebpackPlugin.cjs.js.map
|