Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: compile and bundle monorepo using preconstruct cli #1871

Merged
merged 4 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .changeset/stupid-mice-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@commercetools-backend/express': patch
'@commercetools-backend/loggers': patch
'@commercetools-frontend/actions-global': patch
'@commercetools-frontend/application-components': patch
'@commercetools-frontend/application-config': patch
'@commercetools-frontend/application-shell': patch
'@commercetools-frontend/application-shell-connectors': patch
'@commercetools-frontend/babel-preset-mc-app': patch
'@commercetools-frontend/browser-history': patch
'@commercetools-frontend/constants': patch
'@commercetools-frontend/create-mc-app': patch
'@commercetools-frontend/i18n': patch
'@commercetools-frontend/jest-preset-mc-app': patch
'@commercetools-frontend/l10n': patch
'@commercetools-frontend/mc-html-template': patch
'@commercetools-frontend/mc-scripts': patch
'@commercetools-frontend/notifications': patch
'@commercetools-frontend/permissions': patch
'@commercetools-frontend/react-notifications': patch
'@commercetools-frontend/sdk': patch
'@commercetools-frontend/sentry': patch
'@commercetools-frontend/url-utils': patch
'playground': patch
---

Compile and bundle packages using [preconstruct](https://preconstruct.tools)
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ dist
dist-tarballs
public
packages/application-shell/test-utils
packages/application-shell-connectors/test-utils
packages/sdk/test-utils

# Editor/IDE
.idea
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
presets: ['@commercetools-frontend/babel-preset-mc-app'],
plugins: [
'babel-plugin-import-graphql',
'babel-plugin-typescript-to-proptypes',
],
};
37 changes: 30 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"license": "MIT",
"private": true,
"scripts": {
"postinstall": "preconstruct dev",
"auth": "npm_config_registry=https://registry.npmjs.org npm whoami",
"clean": "lerna exec 'rm -rf build dist'",
"clean": "lerna exec 'rm -rf build dist test-utils/dist'",
"extract-intl": "formatjs extract --format=$(pwd)/packages/i18n/transifex-transformer.js --out-file=$(pwd)/packages/i18n/data/core.json 'packages/**/*messages.ts'",
"compile-intl": "yarn --cwd packages/i18n compile-data",
"l10n:build": "pushd packages/l10n; yarn generate-data",
Expand Down Expand Up @@ -43,11 +44,10 @@
"template-starter:build": "yarn --cwd application-templates/starter build",
"template-starter:start": "yarn --cwd application-templates/starter start",
"template-starter:start:prod:local": "yarn --cwd application-templates/starter start:prod:local",
"build": "NODE_ENV=production lerna run build --no-private",
"build:typings": "NODE_ENV=production lerna run build:typings --no-private",
"build:bundles": "NODE_ENV=production lerna run build:bundles --no-private",
"build:bundles:watch": "NODE_ENV=development lerna run --no-private --parallel build:bundles:watch",
"build:website": "yarn build --scope '@commercetools-frontend/application-components' --include-dependencies && yarn --cwd website build && yarn --cwd website-components-playground build",
"prebuild": "lerna run prebuild --no-private",
"build": "preconstruct build && NODE_ENV=production lerna run build --no-private",
"build:watch": "preconstruct watch & NODE_ENV=development lerna run --no-private --parallel build:bundles:watch",
"build:website": "yarn build && yarn --cwd website build && yarn --cwd website-components-playground build",
"now-build": "yarn build:website && rm -rf public && mv website/public public",
"labels:sync": "github-labels sync",
"generate-types:mc": "./scripts/graphql-cli.sh codegen --project mc",
Expand All @@ -68,7 +68,27 @@
"website-components-playground"
]
},
"devDependencies": {
"preconstruct": {
"packages": [
"packages/actions-global",
"packages/application-components",
"packages/application-config",
"packages/application-shell-connectors",
"packages/browser-history",
"packages/constants",
"packages/i18n",
"packages/l10n",
"packages/notifications",
"packages/permissions",
"packages/react-notifications",
"packages/sdk",
"packages/sentry",
"packages/url-utils",
"packages-backend/express",
"packages-backend/loggers"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also specify packages/* and !packages/foo to have exclusion. At least that's what I did in the flopper.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but there are several packages to exclude. For now I think being explicit is better

]
},
"dependencies": {
"@babel/cli": "7.12.7",
"@babel/core": "7.12.7",
"@changesets/changelog-github": "0.2.7",
Expand All @@ -91,14 +111,17 @@
"@graphql-codegen/typescript-operations": "1.17.10",
"@percy/cypress": "2.3.2",
"@percy/puppeteer": "1.1.0",
"@preconstruct/cli": "2.0.0",
"@rollup/plugin-babel": "5.2.1",
"@rollup/plugin-commonjs": "16.0.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "10.0.0",
"@testing-library/cypress": "7.0.1",
"@testing-library/react": "11.2.2",
"@types/jest-environment-puppeteer": "4.4.0",
"@types/jquery": "3.5.4",
"@types/node": "14.14.9",
"@types/puppeteer": "5.4.0",
"@types/react": "16.14.2",
"@types/react-dom": "16.9.10",
"@types/react-redux": "7.1.11",
Expand Down
13 changes: 5 additions & 8 deletions packages-backend/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
"publishConfig": {
"access": "public"
},
"main": "./build/index.js",
"typings": "./build/index.d.ts",
"types": "./build/index.d.ts",
"files": ["build", "package.json", "LICENSE", "README.md"],
"scripts": {
"prebuild": "rimraf build/**",
"build": "tsc -p tsconfig.build.json"
},
"main": "dist/commercetools-backend-express.cjs.js",
"module": "dist/commercetools-backend-express.esm.js",
"files": ["dist", "package.json", "LICENSE", "README.md"],
"dependencies": {
"@babel/runtime": "7.12.5",
"@babel/runtime-corejs3": "7.12.5",
"@types/node": "14.14.9",
"express": "4.17.1",
"express-jwt": "6.0.0",
Expand Down
12 changes: 0 additions & 12 deletions packages-backend/express/tsconfig.build.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages-backend/express/tsconfig.json

This file was deleted.

13 changes: 5 additions & 8 deletions packages-backend/loggers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
"publishConfig": {
"access": "public"
},
"main": "./build/index.js",
"typings": "./build/index.d.ts",
"types": "./build/index.d.ts",
"files": ["build", "package.json", "LICENSE", "README.md"],
"scripts": {
"prebuild": "rimraf build/**",
"build": "tsc -p tsconfig.build.json"
},
"main": "dist/commercetools-backend-loggers.cjs.js",
"module": "dist/commercetools-backend-loggers.esm.js",
"files": ["dist", "package.json", "LICENSE", "README.md"],
"dependencies": {
"@babel/runtime": "7.12.5",
"@babel/runtime-corejs3": "7.12.5",
"@sentry/node": "5.27.6",
"@types/triple-beam": "1.3.2",
"express-winston": "4.0.5",
Expand Down
11 changes: 0 additions & 11 deletions packages-backend/loggers/tsconfig.build.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages-backend/loggers/tsconfig.json

This file was deleted.

15 changes: 4 additions & 11 deletions packages/actions-global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,21 @@
"publishConfig": {
"access": "public"
},
"main": "./dist/actions-global.cjs.js",
"module": "./dist/actions-global.es.js",
"typings": "./dist/typings/index.d.ts",
"types": "./dist/typings/index.d.ts",
"main": "dist/commercetools-frontend-actions-global.cjs.js",
"module": "dist/commercetools-frontend-actions-global.esm.js",
"files": ["dist", "package.json", "LICENSE", "README.md"],
"scripts": {
"prepare": "./../../scripts/version.js replace",
"prebuild": "rimraf dist/**",
"build": "yarn build:bundles && yarn build:typings",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -i ./src/index.ts",
"build:bundles:watch": "yarn build:bundles -w",
"build:typings": "cross-env tsc -p tsconfig.declarations.json --emitDeclarationOnly --declarationDir dist/typings"
"prepare": "./../../scripts/version.js replace"
},
"dependencies": {
"@babel/runtime": "7.12.5",
"@babel/runtime-corejs3": "7.12.5",
"@commercetools-frontend/browser-history": "17.3.0",
"@commercetools-frontend/constants": "17.3.0",
"@commercetools-frontend/notifications": "17.3.0",
"@commercetools-frontend/sentry": "17.4.1",
"@types/lodash": "^4.14.155",
"lodash": "4.17.20",
"lodash-es": "4.17.15",
"redux-thunk": "2.3.0"
},
"devDependencies": {
Expand Down
6 changes: 0 additions & 6 deletions packages/actions-global/tsconfig.declarations.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/actions-global/tsconfig.json

This file was deleted.

17 changes: 6 additions & 11 deletions packages/application-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
"publishConfig": {
"access": "public"
},
"main": "./dist/application-components.cjs.js",
"module": "./dist/application-components.es.js",
"typings": "./dist/typings/index.d.ts",
"types": "./dist/typings/index.d.ts",
"main": "dist/commercetools-frontend-application-components.cjs.js",
"module": "dist/commercetools-frontend-application-components.esm.js",
"files": [
"dist",
"materials/media-queries.css",
Expand All @@ -27,12 +25,7 @@
"README.md"
],
"scripts": {
"prepare": "./../../scripts/version.js replace",
"prebuild": "rimraf dist/**",
"build": "yarn build:bundles && yarn build:typings",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -i ./src/index.ts",
"build:bundles:watch": "yarn build:bundles -w",
"build:typings": "cross-env tsc -p tsconfig.declarations.json --emitDeclarationOnly --declarationDir dist/typings"
"prepare": "./../../scripts/version.js replace"
},
"dependencies": {
"@babel/runtime": "7.12.5",
Expand All @@ -42,7 +35,10 @@
"@commercetools-frontend/i18n": "17.4.1",
"@commercetools-uikit/card": "^10.42.2",
"@commercetools-uikit/constraints": "^10.42.2",
"@commercetools-uikit/flat-button": "^10.42.2",
"@commercetools-uikit/design-system": "^10.42.2",
"@commercetools-uikit/icon-button": "^10.42.2",
"@commercetools-uikit/icons": "^10.42.2",
"@commercetools-uikit/primary-button": "^10.42.2",
"@commercetools-uikit/secondary-button": "^10.42.2",
"@commercetools-uikit/secondary-icon-button": "^10.42.2",
Expand All @@ -54,7 +50,6 @@
"@types/prop-types": "^15.7.3",
"@types/react-modal": "^3.10.4",
"lodash": "4.17.20",
"lodash-es": "4.17.15",
"prop-types": "15.7.2",
"react-modal": "3.12.1",
"react-required-if": "1.0.3"
Expand Down
43 changes: 5 additions & 38 deletions packages/application-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@
"publishConfig": {
"access": "public"
},
"main": "./build/index.js",
"module": "./build/index.js",
"typings": "./build/typings/src/index.d.ts",
"types": "./build/typings/src/index.d.ts",
"files": ["build", "schema.json", "package.json", "LICENSE", "README.md"],
"main": "dist/commercetools-frontend-application-config.cjs.js",
"module": "dist/commercetools-frontend-application-config.esm.js",
"files": ["dist", "schema.json", "package.json", "LICENSE", "README.md"],
"scripts": {
"prepare": "./../../scripts/version.js replace",
"prebuild": "rimraf build/**",
"build": "yarn build:schema && yarn build:bundles && yarn build:typings",
"build:schema": "json2ts schema.json src/schema.ts --style.singleQuote --bannerComment '/* eslint-disable prettier/prettier */\n// This file was automatically generated by json-schema-to-typescript.\n// DO NOT MODIFY IT BY HAND. Instead, modify the source schema.json file.'",
"build:bundles": "babel src --out-dir build --extensions .ts --ignore src/types.ts,src/schema.ts",
"build:bundles:watch": "yarn build:bundles -w",
"build:typings": "cross-env tsc -p tsconfig.declarations.json --emitDeclarationOnly --declarationDir build/typings"
"prebuild": "yarn build:schema",
"build:schema": "json2ts schema.json src/schema.ts --style.singleQuote --bannerComment '/* eslint-disable prettier/prettier */\n// This file was automatically generated by json-schema-to-typescript.\n// DO NOT MODIFY IT BY HAND. Instead, modify the source schema.json file.'"
},
"dependencies": {
"@babel/runtime": "7.12.5",
Expand All @@ -39,38 +33,11 @@
"omit-empty-es": "1.0.3"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "7.12.1",
"@babel/preset-env": "7.12.7",
"@babel/preset-typescript": "7.12.7",
"json-schema-to-typescript": "9.1.1",
"shelljs": "0.8.4"
},
"engines": {
"node": ">=10",
"npm": ">=5"
},
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "10"
},
"modules": "commonjs",
"useBuiltIns": "usage",
"corejs": 3
}
],
"@babel/preset-typescript"
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"corejs": 3
}
]
]
}
}
6 changes: 0 additions & 6 deletions packages/application-config/tsconfig.declarations.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/application-config/tsconfig.json

This file was deleted.

Loading