diff --git a/packages/catalog-model/package.json b/packages/catalog-model/package.json index 60208aeebb..64f49e34e6 100644 --- a/packages/catalog-model/package.json +++ b/packages/catalog-model/package.json @@ -1,9 +1,7 @@ { "name": "@backstage/catalog-model", "version": "0.1.1-alpha.9", - "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/packages/cli/config/jest.js b/packages/cli/config/jest.js index 4567d8c593..ad24976ad0 100644 --- a/packages/cli/config/jest.js +++ b/packages/cli/config/jest.js @@ -25,32 +25,13 @@ async function getConfig() { return require(path.resolve('jest.config.ts')); } - const moduleNameMapper = { - '\\.(css|less|scss|sss|styl)$': require.resolve('jest-css-modules'), - }; - - // Only point to src/ if we're not in CI, there we just build packages first anyway - if (!process.env.CI) { - const LernaProject = require('@lerna/project'); - const project = new LernaProject(path.resolve('.')); - const packages = await project.getPackages(); - - // To avoid having to build all deps inside the monorepo before running tests, - // we point directory to src/ where applicable. - // For example, @backstage/core = /packages/core/src/index.ts is added to moduleNameMapper - for (const pkg of packages) { - const mainSrc = pkg.get('main:src'); - if (mainSrc) { - moduleNameMapper[`^${pkg.name}$`] = path.resolve(pkg.location, mainSrc); - } - } - } - const options = { rootDir: path.resolve('src'), coverageDirectory: path.resolve('coverage'), collectCoverageFrom: ['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts'], - moduleNameMapper, + moduleNameMapper: { + '\\.(css|less|scss|sss|styl)$': require.resolve('jest-css-modules'), + }, // We build .esm.js files with plugin:build, so to be able to load these in tests they need to be transformed // TODO: jest is working on module support, it's possible that we can remove this in the future diff --git a/packages/cli/src/lib/bundler/config.ts b/packages/cli/src/lib/bundler/config.ts index d5fb674ec1..6fe8092e50 100644 --- a/packages/cli/src/lib/bundler/config.ts +++ b/packages/cli/src/lib/bundler/config.ts @@ -109,7 +109,7 @@ export function createConfig( entry: [require.resolve('react-hot-loader/patch'), paths.targetEntry], resolve: { extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'], - mainFields: ['main:src', 'browser', 'module', 'main'], + mainFields: ['browser', 'module', 'main'], plugins: [ new ModuleScopePlugin( [paths.targetSrc, paths.targetDev], @@ -183,7 +183,7 @@ export function createBackendConfig( ], resolve: { extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'], - mainFields: ['main:src', 'browser', 'module', 'main'], + mainFields: ['browser', 'module', 'main'], modules: [paths.targetNodeModules, paths.rootNodeModules], plugins: [ new ModuleScopePlugin( diff --git a/packages/cli/src/lib/tasks.ts b/packages/cli/src/lib/tasks.ts index 481241a869..b6e2bebb41 100644 --- a/packages/cli/src/lib/tasks.ts +++ b/packages/cli/src/lib/tasks.ts @@ -171,9 +171,7 @@ export async function installWithLocalDeps(dir: string) { }); // This takes care of pointing all the installed packages from this repo to - // dist instead of the local src. - // For example node_modules/@backstage/core/packages.json is rewritten to point - // types to dist/index.d.ts and the main:src field is removed. + // dist instead of the local src, using the field overrides in publishConfig. // Without this we get type checking errors in the e2e test if (process.env.BACKSTAGE_E2E_CLI_TEST) { Task.section('Patching local dependencies for e2e tests'); @@ -192,7 +190,6 @@ export async function installWithLocalDeps(dir: string) { const depJson = await fs.readJson(depJsonPath); // We want dist to be used for e2e tests - delete depJson['main:src']; for (const key of Object.keys(depJson.publishConfig)) { if (key !== 'access') { depJson[key] = depJson.publishConfig[key]; diff --git a/packages/cli/templates/default-app/plugins/welcome/package.json.hbs b/packages/cli/templates/default-app/plugins/welcome/package.json.hbs index c590b68324..d916677d33 100644 --- a/packages/cli/templates/default-app/plugins/welcome/package.json.hbs +++ b/packages/cli/templates/default-app/plugins/welcome/package.json.hbs @@ -1,8 +1,7 @@ { "name": "plugin-welcome", "version": "0.0.0", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "private": true, "publishConfig": { diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index c92795cc04..b04da6b793 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-{{id}}", "version": "{{version}}", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": true, diff --git a/packages/core-api/package.json b/packages/core-api/package.json index 2659a23ef6..4e3c8ef139 100644 --- a/packages/core-api/package.json +++ b/packages/core-api/package.json @@ -18,8 +18,7 @@ "backstage" ], "license": "Apache-2.0", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "backstage-cli build --outputs types,esm", diff --git a/packages/core/package.json b/packages/core/package.json index 01b7ed124d..f84181f626 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -18,8 +18,7 @@ "backstage" ], "license": "Apache-2.0", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "backstage-cli build --outputs types,esm", diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index af1f813148..425d507b17 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -18,8 +18,7 @@ "backstage" ], "license": "Apache-2.0", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "backstage-cli build --outputs types,esm", diff --git a/packages/storybook/.storybook/main.js b/packages/storybook/.storybook/main.js index b8f78f5d2c..2ee58a8c4f 100644 --- a/packages/storybook/.storybook/main.js +++ b/packages/storybook/.storybook/main.js @@ -16,7 +16,7 @@ module.exports = { const coreSrc = path.resolve(__dirname, '../../core/src'); // Mirror config in packages/cli/src/lib/bundler - config.resolve.mainFields = ['main:src', 'browser', 'module', 'main']; + config.resolve.mainFields = ['browser', 'module', 'main']; // Remove the default babel-loader for js files, we're using sucrase instead const [jsLoader] = config.module.rules.splice(0, 1); diff --git a/packages/test-utils-core/package.json b/packages/test-utils-core/package.json index a71a23c844..3b18ff4c1c 100644 --- a/packages/test-utils-core/package.json +++ b/packages/test-utils-core/package.json @@ -18,8 +18,7 @@ "backstage" ], "license": "Apache-2.0", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "backstage-cli build --outputs types,esm", diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 7c5a229aba..c0752f87ac 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -18,8 +18,7 @@ "backstage" ], "license": "Apache-2.0", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "backstage-cli build --outputs types,esm", diff --git a/packages/theme/package.json b/packages/theme/package.json index 72a10eb1f3..1c6c096a8f 100644 --- a/packages/theme/package.json +++ b/packages/theme/package.json @@ -18,8 +18,7 @@ "backstage" ], "license": "Apache-2.0", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "backstage-cli build --outputs types,esm", diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index 54d5737adb..ddffb1f932 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-catalog", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/circleci/package.json b/plugins/circleci/package.json index 0104c5cc7b..f59d93106a 100644 --- a/plugins/circleci/package.json +++ b/plugins/circleci/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-circleci", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/explore/package.json b/plugins/explore/package.json index ad3205f514..74076e9fbb 100644 --- a/plugins/explore/package.json +++ b/plugins/explore/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-explore", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/gitops-profiles/package.json b/plugins/gitops-profiles/package.json index c9dca36e08..ee4406be4c 100644 --- a/plugins/gitops-profiles/package.json +++ b/plugins/gitops-profiles/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-gitops-profiles", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/graphiql/package.json b/plugins/graphiql/package.json index 49293acbfb..9d4a797c82 100644 --- a/plugins/graphiql/package.json +++ b/plugins/graphiql/package.json @@ -18,8 +18,7 @@ "backstage" ], "license": "Apache-2.0", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "scripts": { "build": "backstage-cli plugin:build", diff --git a/plugins/lighthouse/package.json b/plugins/lighthouse/package.json index a3c65d05ea..c96013a814 100644 --- a/plugins/lighthouse/package.json +++ b/plugins/lighthouse/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-lighthouse", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/register-component/package.json b/plugins/register-component/package.json index d999ab1dcc..e4c84e448d 100644 --- a/plugins/register-component/package.json +++ b/plugins/register-component/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-register-component", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/scaffolder/package.json b/plugins/scaffolder/package.json index 84132a42f9..5c6859cf57 100644 --- a/plugins/scaffolder/package.json +++ b/plugins/scaffolder/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-scaffolder", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/sentry/package.json b/plugins/sentry/package.json index 7a8197ab87..80435cf38a 100644 --- a/plugins/sentry/package.json +++ b/plugins/sentry/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-sentry", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/tech-radar/package.json b/plugins/tech-radar/package.json index e0146e8a72..16a36dba5d 100644 --- a/plugins/tech-radar/package.json +++ b/plugins/tech-radar/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-tech-radar", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", "private": false, diff --git a/plugins/welcome/package.json b/plugins/welcome/package.json index 6780f7df98..deed9012da 100644 --- a/plugins/welcome/package.json +++ b/plugins/welcome/package.json @@ -1,8 +1,7 @@ { "name": "@backstage/plugin-welcome", "version": "0.1.1-alpha.9", - "main": "dist/index.esm.js", - "main:src": "src/index.ts", + "main": "src/index.ts", "types": "src/index.ts", "private": false, "license": "Apache-2.0",