diff --git a/packages/component-library-angular/CONTRIBUTING.md b/packages/component-library-angular/CONTRIBUTING.md deleted file mode 100644 index 2ef832ac272..00000000000 --- a/packages/component-library-angular/CONTRIBUTING.md +++ /dev/null @@ -1,11 +0,0 @@ -# Contributing to the Angular component library - -## npm package - -The Angular packager builds a `package.json` file in the `dist/` directory. The Angular build process takes the responsibility to configure the exports in various properties (such as the `exports` and `typings` properties). - -We haven't found a way to publish the package from `dist/` using our current setup, so as a workaround we have manually copied the export properties from `dist/package.json` to `package.json` and corrected the paths to point to the `dist/` directory. - -When you upgrade Angular, you will need to manually ensure the configurations are still in sync. - -We included a test script `test-export.mjs` to warn when the configurations are out of sync. diff --git a/packages/component-library-angular/package.json b/packages/component-library-angular/package.json index a5b39e306c1..b5833a1f128 100644 --- a/packages/component-library-angular/package.json +++ b/packages/component-library-angular/package.json @@ -28,7 +28,6 @@ "watch:build": "ng build --watch", "test-results": "jest --json --outputFile=dist/.jest-test-results.json --silent", "test": "jest --verbose", - "test-build": "node test-exports.mjs", "watch:test": "NODE_OPTIONS=--experimental-vm-modules jest --verbose --watch" }, "dependencies": { diff --git a/packages/component-library-angular/test-exports.mjs b/packages/component-library-angular/test-exports.mjs deleted file mode 100644 index 515b7687c8c..00000000000 --- a/packages/component-library-angular/test-exports.mjs +++ /dev/null @@ -1,50 +0,0 @@ -import packageJSON from './package.json' assert { type: 'json' }; -import distPackageJSON from './dist/package.json' assert { type: 'json' }; -import { dirname, resolve } from 'node:path'; -import { access, constants } from 'node:fs/promises'; -import isEqual from 'lodash.isequal'; -import cloneDeepWith from 'lodash.clonedeepwith'; - -const getSubset = (pkg) => ({ - module: pkg.module, - typings: pkg.typings, - exports: pkg.exports, -}); - -const getAbsoluteSubset = (base, pkg) => - cloneDeepWith(getSubset(pkg), (value) => (typeof value === 'string' ? resolve(base, value) : undefined)); - -const getPaths = (pkg) => - [ - pkg.module, - pkg.typings, - ...(pkg.exports - ? Object.values(pkg.exports) - .map((item) => Object.values(item)) - .reduce((a, b) => [...a, ...b], []) - : []), - ].filter(Boolean); - -const getAbsolutePaths = (base, pkg) => getPaths(pkg).map((path) => resolve(base, path)); - -const testPathExistence = (paths) => - paths - .map((path) => resolve(path)) - .forEach(async (path) => { - try { - await access(path, constants.R_OK); - console.log(`File exists: ${path}`); - } catch (e) { - throw new Error(`Cannot find file mentioned in package.json: ${path}`); - } - }); - -const subset = getAbsoluteSubset('', packageJSON); -const referenceSubset = getAbsoluteSubset('dist/', distPackageJSON); - -if (!isEqual(subset, referenceSubset)) { - console.log(`package.json:\n${JSON.stringify(subset, null, 2)}`); - console.log(`dist/package.json:\n${JSON.stringify(referenceSubset, null, 2)}`); - - throw new Error('Exports of package.json and dist/package.json are not in sync. See CONTRIBUTING.md for more info.'); -}