From a49c69eb9c79c34d17c0485c6b9837fbaaaa48e7 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 6 Feb 2020 13:11:39 +0000 Subject: [PATCH 1/2] Use src directory when plugins are linked to each other --- .storybook/webpack.config.js | 6 ++++-- _element-template/package.json | 1 + babel.config.js | 3 ++- src/compounds/side-nav/package.json | 1 + src/elements/accordion/package.json | 1 + src/elements/author/package.json | 1 + src/elements/breadcrumbs/package.json | 1 + src/elements/bullet-list-highlight/package.json | 1 + src/elements/bullet-list-timeline/package.json | 1 + src/elements/button-link/package.json | 1 + src/elements/button/package.json | 1 + src/elements/call-out/package.json | 1 + src/elements/category/package.json | 1 + src/elements/checkbox-input/package.json | 1 + src/elements/cta/package.json | 1 + src/elements/drop-down/package.json | 1 + src/elements/embedded-video/package.json | 1 + src/elements/fieldset/package.json | 1 + src/elements/frozen-input/package.json | 1 + src/elements/global-styles/package.json | 1 + src/elements/icon/package.json | 1 + src/elements/imgix-image/package.json | 1 + src/elements/input-alert/package.json | 1 + src/elements/input/package.json | 1 + src/elements/list/package.json | 1 + src/elements/loading-spinner/package.json | 1 + src/elements/pagination/package.json | 1 + src/elements/progress-bar/package.json | 1 + src/elements/radio-input/package.json | 1 + src/elements/side-drawer/package.json | 1 + src/elements/tile-input/package.json | 1 + src/helpers/date/package.json | 1 + src/layout/arrangement/package.json | 1 + src/layout/grid/package.json | 1 + src/styles/package.json | 1 + 35 files changed, 39 insertions(+), 3 deletions(-) diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index bd49fa00e..6a626fea0 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -1,12 +1,14 @@ module.exports = ({ config }) => { config.module.rules.push({ test: /\.tsx?$/, - exclude: /node_modules/, loader: 'babel-loader', options: { - presets: ["@babel/typescript", "@babel/preset-react"] + presets: ['@babel/typescript', '@babel/preset-react'] } }) config.resolve.extensions.push('.ts', '.tsx') + + config.resolve.mainFields = ['ts:main', 'main'] + return config } diff --git a/_element-template/package.json b/_element-template/package.json index 111a26b0c..48bfe666b 100644 --- a/_element-template/package.json +++ b/_element-template/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/babel.config.js b/babel.config.js index 3e339dfa7..d0caa9516 100644 --- a/babel.config.js +++ b/babel.config.js @@ -14,6 +14,7 @@ module.exports = api => { } }, presets: ['@babel/typescript', '@babel/preset-react'], - plugins: ['@babel/plugin-proposal-optional-chaining'] + plugins: ['@babel/plugin-proposal-optional-chaining'], + sourceType: 'unambiguous' } } diff --git a/src/compounds/side-nav/package.json b/src/compounds/side-nav/package.json index 3dc8230d3..be7de7128 100644 --- a/src/compounds/side-nav/package.json +++ b/src/compounds/side-nav/package.json @@ -3,6 +3,7 @@ "version": "0.1.2", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/accordion/package.json b/src/elements/accordion/package.json index 46e277a08..b136ff91a 100644 --- a/src/elements/accordion/package.json +++ b/src/elements/accordion/package.json @@ -3,6 +3,7 @@ "version": "0.1.8", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/author/package.json b/src/elements/author/package.json index 458e2b81c..cac86fa9c 100644 --- a/src/elements/author/package.json +++ b/src/elements/author/package.json @@ -3,6 +3,7 @@ "version": "0.1.3", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/breadcrumbs/package.json b/src/elements/breadcrumbs/package.json index 0afcf7a74..875986cab 100644 --- a/src/elements/breadcrumbs/package.json +++ b/src/elements/breadcrumbs/package.json @@ -3,6 +3,7 @@ "version": "0.0.8", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/bullet-list-highlight/package.json b/src/elements/bullet-list-highlight/package.json index 786e23513..8acedb0ef 100644 --- a/src/elements/bullet-list-highlight/package.json +++ b/src/elements/bullet-list-highlight/package.json @@ -3,6 +3,7 @@ "version": "0.2.48", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "scripts": { "--------------- BUILDING": "----------------------", "clean": "rm -rf lib", diff --git a/src/elements/bullet-list-timeline/package.json b/src/elements/bullet-list-timeline/package.json index de9a5046a..cff555294 100644 --- a/src/elements/bullet-list-timeline/package.json +++ b/src/elements/bullet-list-timeline/package.json @@ -3,6 +3,7 @@ "version": "0.2.41", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/button-link/package.json b/src/elements/button-link/package.json index 472827d54..7bb824f4a 100644 --- a/src/elements/button-link/package.json +++ b/src/elements/button-link/package.json @@ -3,6 +3,7 @@ "version": "0.3.8", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/button/package.json b/src/elements/button/package.json index 206a328cd..1ce2557b2 100644 --- a/src/elements/button/package.json +++ b/src/elements/button/package.json @@ -3,6 +3,7 @@ "version": "0.7.7", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/call-out/package.json b/src/elements/call-out/package.json index 09d59d765..53a0bb414 100644 --- a/src/elements/call-out/package.json +++ b/src/elements/call-out/package.json @@ -3,6 +3,7 @@ "version": "0.1.8", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/category/package.json b/src/elements/category/package.json index e8b0da0cb..27b3f66c5 100644 --- a/src/elements/category/package.json +++ b/src/elements/category/package.json @@ -3,6 +3,7 @@ "version": "0.1.7", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/checkbox-input/package.json b/src/elements/checkbox-input/package.json index f107d7a55..98c833626 100644 --- a/src/elements/checkbox-input/package.json +++ b/src/elements/checkbox-input/package.json @@ -3,6 +3,7 @@ "version": "0.0.21", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/cta/package.json b/src/elements/cta/package.json index 546556763..74b225af9 100644 --- a/src/elements/cta/package.json +++ b/src/elements/cta/package.json @@ -3,6 +3,7 @@ "version": "0.1.7", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/drop-down/package.json b/src/elements/drop-down/package.json index 1ffe3ec98..31002965f 100644 --- a/src/elements/drop-down/package.json +++ b/src/elements/drop-down/package.json @@ -3,6 +3,7 @@ "version": "0.4.55", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/embedded-video/package.json b/src/elements/embedded-video/package.json index fb341fa08..85db53c3a 100644 --- a/src/elements/embedded-video/package.json +++ b/src/elements/embedded-video/package.json @@ -3,6 +3,7 @@ "version": "0.1.3", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/fieldset/package.json b/src/elements/fieldset/package.json index b592d2a05..f80a3877f 100644 --- a/src/elements/fieldset/package.json +++ b/src/elements/fieldset/package.json @@ -3,6 +3,7 @@ "version": "0.0.21", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/frozen-input/package.json b/src/elements/frozen-input/package.json index d8c04cef0..f9c4a9ad2 100644 --- a/src/elements/frozen-input/package.json +++ b/src/elements/frozen-input/package.json @@ -3,6 +3,7 @@ "version": "0.3.48", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/global-styles/package.json b/src/elements/global-styles/package.json index 42c2aebf1..68b88a061 100644 --- a/src/elements/global-styles/package.json +++ b/src/elements/global-styles/package.json @@ -3,6 +3,7 @@ "version": "0.3.7", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/icon/package.json b/src/elements/icon/package.json index 3cf14bee6..6688ebd87 100644 --- a/src/elements/icon/package.json +++ b/src/elements/icon/package.json @@ -3,6 +3,7 @@ "version": "0.2.47", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/imgix-image/package.json b/src/elements/imgix-image/package.json index 0972fa083..b61350dd6 100644 --- a/src/elements/imgix-image/package.json +++ b/src/elements/imgix-image/package.json @@ -3,6 +3,7 @@ "version": "0.1.24", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/input-alert/package.json b/src/elements/input-alert/package.json index 4da5bd5e9..a05e9f118 100644 --- a/src/elements/input-alert/package.json +++ b/src/elements/input-alert/package.json @@ -3,6 +3,7 @@ "version": "0.2.41", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/input/package.json b/src/elements/input/package.json index f865d7e5e..11fae62ca 100644 --- a/src/elements/input/package.json +++ b/src/elements/input/package.json @@ -3,6 +3,7 @@ "version": "0.3.48", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/list/package.json b/src/elements/list/package.json index 560d4c33e..f49967807 100644 --- a/src/elements/list/package.json +++ b/src/elements/list/package.json @@ -3,6 +3,7 @@ "version": "0.2.7", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/loading-spinner/package.json b/src/elements/loading-spinner/package.json index bedb483c1..1b3644fea 100644 --- a/src/elements/loading-spinner/package.json +++ b/src/elements/loading-spinner/package.json @@ -3,6 +3,7 @@ "version": "0.2.41", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/pagination/package.json b/src/elements/pagination/package.json index 0d04f7fad..19e9a81fe 100644 --- a/src/elements/pagination/package.json +++ b/src/elements/pagination/package.json @@ -3,6 +3,7 @@ "version": "0.1.8", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/progress-bar/package.json b/src/elements/progress-bar/package.json index 70ad6021b..6f43ac44c 100644 --- a/src/elements/progress-bar/package.json +++ b/src/elements/progress-bar/package.json @@ -3,6 +3,7 @@ "version": "0.3.15", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/radio-input/package.json b/src/elements/radio-input/package.json index 33d7c5e7c..dc8922ee7 100644 --- a/src/elements/radio-input/package.json +++ b/src/elements/radio-input/package.json @@ -3,6 +3,7 @@ "version": "1.1.13", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/side-drawer/package.json b/src/elements/side-drawer/package.json index c6c2c317f..b64862402 100644 --- a/src/elements/side-drawer/package.json +++ b/src/elements/side-drawer/package.json @@ -3,6 +3,7 @@ "version": "0.2.35", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/elements/tile-input/package.json b/src/elements/tile-input/package.json index f4e76ac8a..e6d21ee63 100644 --- a/src/elements/tile-input/package.json +++ b/src/elements/tile-input/package.json @@ -3,6 +3,7 @@ "version": "1.0.48", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/helpers/date/package.json b/src/helpers/date/package.json index e5b7a6b10..bdce714b3 100644 --- a/src/helpers/date/package.json +++ b/src/helpers/date/package.json @@ -3,6 +3,7 @@ "version": "0.0.5", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/layout/arrangement/package.json b/src/layout/arrangement/package.json index c30ce4bda..5463629eb 100644 --- a/src/layout/arrangement/package.json +++ b/src/layout/arrangement/package.json @@ -3,6 +3,7 @@ "version": "2.0.6", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/layout/grid/package.json b/src/layout/grid/package.json index 80e687aa7..f8e0cdb1b 100644 --- a/src/layout/grid/package.json +++ b/src/layout/grid/package.json @@ -3,6 +3,7 @@ "version": "1.0.19", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.tsx", "publishConfig": { "access": "public" }, diff --git a/src/styles/package.json b/src/styles/package.json index b52aab4a1..f9063f056 100644 --- a/src/styles/package.json +++ b/src/styles/package.json @@ -3,6 +3,7 @@ "version": "0.4.23", "license": "MIT", "main": "lib/index.js", + "ts:main": "src/index.ts", "publishConfig": { "access": "public" }, From b00ea26601734287b40e89c65ed5791f7fa20100 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 6 Feb 2020 14:59:36 +0000 Subject: [PATCH 2/2] Update readme --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4af67bd91..610b81015 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ ## Development All commands can be run from individual packages, but it is not necessary to do so. -Run `npm install` at the project root to install the dev dependencies. -Run `npx lerna exec 'npm install'` to install each package’s dependencies. -Run `npx lerna bootstrap` to install each package’s dependencies. -Run `npx lerna run build` to run each package’s build script. +- Run `npm install` at the project root to install the dev dependencies. +- Run `npx lerna exec 'npm install'` to install each package’s dependencies. +- Run `npx lerna bootstrap` to link package dependencies to each other. To run storybook locally `npm start`. +To run each package’s build script, run `npx lerna run build`. You don't usually have to do this as you don't need it for local development and the publish script runs it for you on publish. + To add a new element, copy the template to the src/elements directory, update the package.json with the name and add your source code. ## TODO: