Skip to content

Commit

Permalink
fix: Remove package exports and replace subpaths script (#8438)
Browse files Browse the repository at this point in the history
* fix: Remove package exports and replace subpaths script

* adding more subpaths in the event 'next' or 'deprecated' have relative paths
  • Loading branch information
jpuzz0 authored Dec 12, 2022
1 parent caf893d commit 75bea27
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 21 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@
"typescript": "^4.0.0"
},
"scripts": {
"build": "yarn build:generate && yarn build:esm && yarn build:cjs",
"build": "yarn build:generate && yarn build:esm && yarn build:subpaths && yarn build:cjs",
"build:cjs": "tsc --build --verbose packages/tsconfig.cjs.json",
"build:esm": "tsc --build --verbose packages/tsconfig.json",
"build:integration": "lerna run build:demo-app --stream",
"build:docs": "yarn workspace @patternfly/react-docs build:docs",
"build:generate": "lerna run generate --parallel --stream",
"build:subpaths": "lerna run subpaths --parallel --stream",
"build:umd": "lerna run build:umd --parallel --stream",
"clean": "yarn clean:build && lerna run clean --parallel",
"clean:build": "rimraf .cache .eslintcache coverage",
Expand Down
5 changes: 5 additions & 0 deletions packages/react-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/next
/deprecated
/components
/layouts
/helpers
10 changes: 2 additions & 8 deletions packages/react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
"main": "dist/js/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"exports": {
".": "./dist/esm/index.js",
"./dist/*": "./dist/*",
"./next": "./dist/esm/next",
"./deprecated": "./dist/esm/deprecated",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"next": [
Expand Down Expand Up @@ -48,7 +41,8 @@
"scripts": {
"build:umd": "rollup -c --environment IS_PRODUCTION",
"clean": "rimraf dist",
"generate": "node scripts/copyStyles.js"
"generate": "node scripts/copyStyles.js",
"subpaths": "node scripts/copySubpaths.js"
},
"dependencies": {
"@patternfly/react-icons": "^4.93.3",
Expand Down
12 changes: 12 additions & 0 deletions packages/react-core/scripts/copySubpaths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copy subpath modules into the package root directory for ease of access.
*/
const { copySync } = require('fs-extra');
const { resolve, dirname } = require('path');

['next', 'deprecated', 'components', 'layouts', 'helpers'].forEach(subPathName => {
const source = dirname(require.resolve(`@patternfly/react-core/dist/esm/${subPathName}`));
const destination = resolve(__dirname, `../${subPathName}`);

copySync(source, destination);
});
9 changes: 3 additions & 6 deletions packages/react-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
"tsBuildInfoFile": "dist/esm.tsbuildinfo",
"baseUrl": ".",
"paths": {
"*/next": ["./src/next"],
"*/deprecated": ["./src/deprecated"],
"./next": ["./src/next"],
"./deprecated": ["./src/deprecated"]
}
},
"include": [
"./src/*",
"./src/**/*"
],
"include": ["./src/*", "./src/**/*"],
"references": [
{
"path": "../react-styles"
Expand Down
2 changes: 2 additions & 0 deletions packages/react-table/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/deprecated
/components
8 changes: 2 additions & 6 deletions packages/react-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"main": "dist/js/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"exports": {
".": "./dist/esm/index.js",
"./deprecated": "./dist/esm/deprecated/index.js",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"deprecated": [
Expand Down Expand Up @@ -40,7 +35,8 @@
"homepage": "https://github.com/patternfly/patternfly-react/tree/main/packages/react-table#readme",
"scripts": {
"build:umd": "rollup -c --environment IS_PRODUCTION",
"clean": "rimraf dist"
"clean": "rimraf dist",
"subpaths": "node scripts/copySubpaths.js"
},
"dependencies": {
"@patternfly/react-core": "^4.267.5",
Expand Down
12 changes: 12 additions & 0 deletions packages/react-table/scripts/copySubpaths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copy subpath modules into the package root directory for ease of access.
*/
const { copySync } = require('fs-extra');
const { resolve, dirname } = require('path');

['deprecated', 'components'].forEach(subPathName => {
const source = dirname(require.resolve(`@patternfly/react-table/dist/esm/${subPathName}`));
const destination = resolve(__dirname, `../${subPathName}`);

copySync(source, destination);
});

0 comments on commit 75bea27

Please sign in to comment.