From 364f540b981cda0e212167fd89a4133af24c6519 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Wed, 23 Sep 2020 00:40:35 +0200 Subject: [PATCH] [core] Inline x-grid-modules --- .gitignore | 1 + package.json | 4 +- packages/grid/data-grid/package.json | 5 +- packages/grid/data-grid/replaces.js | 7 ++ packages/grid/data-grid/rollup.config.js | 10 +-- packages/grid/data-grid/tsconfig.build.json | 9 +-- packages/grid/x-grid/package.json | 5 +- packages/grid/x-grid/replaces.js | 7 ++ packages/grid/x-grid/rollup.config.js | 11 +--- packages/grid/x-grid/tsconfig.build.json | 17 +++++ packages/grid/x-grid/tsconfig.json | 7 +- yarn.lock | 71 +++++++++++++++++++-- 12 files changed, 112 insertions(+), 42 deletions(-) create mode 100644 packages/grid/data-grid/replaces.js create mode 100644 packages/grid/x-grid/replaces.js create mode 100644 packages/grid/x-grid/tsconfig.build.json diff --git a/.gitignore b/.gitignore index 3969bda46191d..192bb2c514f3b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ __diff_output__ /docs/.next /docs/export dist +build node_modules diff --git a/package.json b/package.json index 1358ebab71538..7e8fffaa5256e 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,6 @@ "react-dom": "^16.13.1", "rollup": "^2.6.1", "rollup-plugin-cleaner": "^1.0.0", - "rollup-plugin-command": "^1.1.3", "rollup-plugin-dts": "^1.4.7", "rollup-plugin-sourcemaps": "^0.6.2", "rollup-plugin-terser": "^5.3.0", @@ -122,5 +121,8 @@ "nohoist": [ "**/@material-ui/monorepo" ] + }, + "dependencies": { + "replace-in-files": "^2.0.3" } } diff --git a/packages/grid/data-grid/package.json b/packages/grid/data-grid/package.json index 5889d93d9b578..dfb612ce46bca 100644 --- a/packages/grid/data-grid/package.json +++ b/packages/grid/data-grid/package.json @@ -5,7 +5,7 @@ "author": "Material-UI Team", "main": "dist/index-cjs.js", "module": "dist/index-esm.js", - "types": "dist/data-grid.all.d.ts", + "types": "dist/data-grid.d.ts", "files": [ "dist/*" ], @@ -26,7 +26,8 @@ ], "scripts": { "precommit": "npm run lint", - "build": "rollup -c ", + "prebuild": "rimraf build", + "build": "cp -r ./src ./build && mkdir ./build/x-grid-modules && cp -r ../x-grid-modules/src ./build/x-grid-modules/src && cp -r ../x-grid-modules/lib/ ./build/x-grid-modules/lib && node replaces.js && rollup -c", "start": "rollup -cw", "lint": "eslint 'src/**/*.{ts,tsx}' --quiet --fix -c ../../../.eslintrc.js && npm run lint:css", "lint:css": "stylelint 'src/**/*.{ts,tsx}' ../../../.stylelintrc.js", diff --git a/packages/grid/data-grid/replaces.js b/packages/grid/data-grid/replaces.js new file mode 100644 index 0000000000000..dc173c2f21275 --- /dev/null +++ b/packages/grid/data-grid/replaces.js @@ -0,0 +1,7 @@ +const replaceInFiles = require('replace-in-files'); + +replaceInFiles({ + files: 'build/*', + from: '@material-ui/x-grid-modules', + to: './x-grid-modules/src', +}); diff --git a/packages/grid/data-grid/rollup.config.js b/packages/grid/data-grid/rollup.config.js index dcc0cf56e9355..0d7910b97086a 100644 --- a/packages/grid/data-grid/rollup.config.js +++ b/packages/grid/data-grid/rollup.config.js @@ -4,14 +4,13 @@ import cleaner from 'rollup-plugin-cleaner'; import sourceMaps from 'rollup-plugin-sourcemaps'; import { terser } from 'rollup-plugin-terser'; import dts from 'rollup-plugin-dts'; -import command from 'rollup-plugin-command'; import pkg from './package.json'; // dev build if watching, prod build if not const production = !process.env.ROLLUP_WATCH; export default [ { - input: 'src/index.ts', + input: 'build/index.ts', output: [ { file: 'dist/index-esm.js', @@ -43,13 +42,6 @@ export default [ output: [{ file: 'dist/data-grid.d.ts', format: 'es' }], plugins: [ dts(), - command( - `cat ../x-grid-modules/dist/x-grid-modules.d.ts ./dist/data-grid.d.ts > ./dist/data-grid.all.d.ts`, - { - exitOnFail: true, - wait: true, - }, - ), !production && sourceMaps(), ], }, diff --git a/packages/grid/data-grid/tsconfig.build.json b/packages/grid/data-grid/tsconfig.build.json index 1a4295d2eb0e8..0dc8fe101fc0b 100644 --- a/packages/grid/data-grid/tsconfig.build.json +++ b/packages/grid/data-grid/tsconfig.build.json @@ -12,11 +12,6 @@ "sourceMap": true, "build": true }, - "include": ["src"], - "exclude": ["__tests__", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.tsx", "node_modules", "lib"], - "references": [ - { - "path": "../x-grid-modules" - } - ] + "include": ["build"], + "exclude": ["__tests__", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.tsx", "node_modules", "lib"] } diff --git a/packages/grid/x-grid/package.json b/packages/grid/x-grid/package.json index 10033e9644fd7..d9116019c0398 100644 --- a/packages/grid/x-grid/package.json +++ b/packages/grid/x-grid/package.json @@ -5,7 +5,7 @@ "author": "Material-UI Team", "main": "dist/index-cjs.js", "module": "dist/index-esm.js", - "types": "dist/x-grid.all.d.ts", + "types": "dist/x-grid.d.ts", "files": [ "dist/*" ], @@ -38,7 +38,8 @@ }, "scripts": { "precommit": "npm run lint", - "build": "rollup -c ", + "prebuild": "rimraf build", + "build": "cp -r ./src ./build && mkdir ./build/x-grid-modules && cp -r ../x-grid-modules/src ./build/x-grid-modules/src && cp -r ../x-grid-modules/lib/ ./build/x-grid-modules/lib && node replaces.js && rollup -c", "prepublishOnly": "npm run build", "start": "rollup -cw", "lint": "../../../node_modules/.bin/tsc --noEmit && eslint 'src/**/*.{ts,tsx}' --quiet --fix -c ../../../.eslintrc.js && npm run lint:css", diff --git a/packages/grid/x-grid/replaces.js b/packages/grid/x-grid/replaces.js new file mode 100644 index 0000000000000..dc173c2f21275 --- /dev/null +++ b/packages/grid/x-grid/replaces.js @@ -0,0 +1,7 @@ +const replaceInFiles = require('replace-in-files'); + +replaceInFiles({ + files: 'build/*', + from: '@material-ui/x-grid-modules', + to: './x-grid-modules/src', +}); diff --git a/packages/grid/x-grid/rollup.config.js b/packages/grid/x-grid/rollup.config.js index 6bb39df233d1b..93e6b294fdb40 100644 --- a/packages/grid/x-grid/rollup.config.js +++ b/packages/grid/x-grid/rollup.config.js @@ -6,14 +6,13 @@ import { terser } from 'rollup-plugin-terser'; import replace from '@rollup/plugin-replace'; import resolve from '@rollup/plugin-node-resolve'; import dts from 'rollup-plugin-dts'; -import command from 'rollup-plugin-command'; import pkg from './package.json'; // dev build if watching, prod build if not const production = !process.env.ROLLUP_WATCH; export default [ { - input: 'src/index.ts', + input: 'build/index.ts', output: [ { file: 'dist/index-esm.js', @@ -38,7 +37,7 @@ export default [ cleaner({ targets: ['./dist/'], }), - typescript(), + typescript({ tsconfig: 'tsconfig.build.json' }), !production && sourceMaps(), production && terser(), ], @@ -48,11 +47,7 @@ export default [ output: [{ file: 'dist/x-grid.d.ts', format: 'es' }], plugins: [ dts(), - command( - `cat ../../x-license/dist/x-license.d.ts ../x-grid-modules/dist/x-grid-modules.d.ts ./dist/x-grid.d.ts > ./dist/x-grid.all.d.ts`, - { exitOnFail: true, wait: true }, - !production && sourceMaps(), - ), + !production && sourceMaps(), ], }, ]; diff --git a/packages/grid/x-grid/tsconfig.build.json b/packages/grid/x-grid/tsconfig.build.json new file mode 100644 index 0000000000000..0dc8fe101fc0b --- /dev/null +++ b/packages/grid/x-grid/tsconfig.build.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "baseUrl": "./", + "declaration": true, + "declarationDir": "./dist", + "module": "es6", + "noImplicitAny": false, + "strict": true, + "outDir": "./dist", + "target": "es6", + "sourceMap": true, + "build": true + }, + "include": ["build"], + "exclude": ["__tests__", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.tsx", "node_modules", "lib"] +} diff --git a/packages/grid/x-grid/tsconfig.json b/packages/grid/x-grid/tsconfig.json index 1a4295d2eb0e8..a9799614d7170 100644 --- a/packages/grid/x-grid/tsconfig.json +++ b/packages/grid/x-grid/tsconfig.json @@ -13,10 +13,5 @@ "build": true }, "include": ["src"], - "exclude": ["__tests__", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.tsx", "node_modules", "lib"], - "references": [ - { - "path": "../x-grid-modules" - } - ] + "exclude": ["__tests__", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.tsx", "node_modules", "lib"] } diff --git a/yarn.lock b/yarn.lock index e4968597cbf2e..4766203dfec5f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6793,6 +6793,11 @@ binary-extensions@^2.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9" integrity sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ== +binaryextensions@^2.1.2: + version "2.3.0" + resolved "https://registry.yarnpkg.com/binaryextensions/-/binaryextensions-2.3.0.tgz#1d269cbf7e6243ea886aa41453c3651ccbe13c22" + integrity sha512-nAihlQsYGyc5Bwq6+EsubvANYGExeJKHDO3RjnvwU042fawQTQfM3Kxn7IHUXQOz4bzfwsGYYHGSvXyW4zOGLg== + bindings@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" @@ -9398,6 +9403,14 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" +editions@^2.2.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/editions/-/editions-2.3.1.tgz#3bc9962f1978e801312fbd0aebfed63b49bfe698" + integrity sha512-ptGvkwTvGdGfC0hfhKg0MT+TRLRKGtUiWGBInxOm5pz7ssADezahjCUaYuZ8Dr+C05FW0AECIIPt4WBxVINEhA== + dependencies: + errlop "^2.0.0" + semver "^6.3.0" + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -9678,6 +9691,11 @@ err-code@^1.0.0: resolved "https://registry.yarnpkg.com/err-code/-/err-code-1.1.2.tgz#06e0116d3028f6aef4806849eb0ea6a748ae6960" integrity sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA= +errlop@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/errlop/-/errlop-2.2.0.tgz#1ff383f8f917ae328bebb802d6ca69666a42d21b" + integrity sha512-e64Qj9+4aZzjzzFpZC7p5kmm/ccCrbLhAJplhsDXQFs87XTsXwOpH4s1Io2s90Tau/8r2j9f4l/thhDevRjzxw== + errno@^0.1.1, errno@^0.1.3, errno@~0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618" @@ -9776,6 +9794,11 @@ es6-promisify@^5.0.0: dependencies: es6-promise "^4.0.3" +es6-promisify@^6.0.2: + version "6.1.1" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-6.1.1.tgz#46837651b7b06bf6fff893d03f29393668d01621" + integrity sha512-HBL8I3mIki5C1Cc9QjKUenHtnG0A5/xA8Q/AllRcfiwl2CZFXGK7ddBiCoRwAix4i2KxcQfjtIVcrVbB3vbmwg== + es6-shim@^0.35.5: version "0.35.5" resolved "https://registry.yarnpkg.com/es6-shim/-/es6-shim-0.35.5.tgz#46f59dc0a84a1c5029e8ff1166ca0a902077a9ab" @@ -10403,7 +10426,7 @@ fast-glob@^2.0.2, fast-glob@^2.2.6: merge2 "^1.2.3" micromatch "^3.1.10" -fast-glob@^3.1.1, fast-glob@^3.2.4: +fast-glob@^3.0.3, fast-glob@^3.1.1, fast-glob@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.4.tgz#d20aefbf99579383e7f3cc66529158c9b98554d3" integrity sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ== @@ -11309,6 +11332,20 @@ globby@8.0.2: pify "^3.0.0" slash "^1.0.0" +globby@^10.0.1: + version "10.0.2" + resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.2.tgz#277593e745acaa4646c3ab411289ec47a0392543" + integrity sha512-7dUi7RvCoT/xast/o/dLN53oqND4yk0nsHkhRgn9w65C4PofCLOoJ39iSOg+qVDdWQPIEj+eszMHQ+aLVwwQSg== + dependencies: + "@types/glob" "^7.1.1" + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.0.3" + glob "^7.1.3" + ignore "^5.1.1" + merge2 "^1.2.3" + slash "^3.0.0" + globby@^11.0.1: version "11.0.1" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357" @@ -12009,7 +12046,7 @@ ignore@^4.0.3, ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.0.5, ignore@^5.1.4, ignore@^5.1.8: +ignore@^5.0.5, ignore@^5.1.1, ignore@^5.1.4, ignore@^5.1.8: version "5.1.8" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== @@ -12882,6 +12919,15 @@ istanbul-reports@^3.0.2: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" +istextorbinary@^2.5.1: + version "2.6.0" + resolved "https://registry.yarnpkg.com/istextorbinary/-/istextorbinary-2.6.0.tgz#60776315fb0fa3999add276c02c69557b9ca28ab" + integrity sha512-+XRlFseT8B3L9KyjxxLjfXSLMuErKDsd8DBNrsaxoViABMEZlOSCstwmw0qpoFX3+U6yWU1yhLudAe6/lETGGA== + dependencies: + binaryextensions "^2.1.2" + editions "^2.2.0" + textextensions "^2.5.0" + iterate-iterator@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/iterate-iterator/-/iterate-iterator-1.0.1.tgz#1693a768c1ddd79c969051459453f082fe82e9f6" @@ -18510,6 +18556,17 @@ replace-ext@1.0.0: resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" integrity sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs= +replace-in-files@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/replace-in-files/-/replace-in-files-2.0.3.tgz#2e20f3a06fb50abb9e77e689da6a0cf2bbd70f17" + integrity sha512-wm9kg+WhKQ10CFaCS9jvUtgw9JnaPilm4TqSRq57H06v5EgX7hTrr/qwgyvq3G+IeNhmr6VTW84LvfnpZfq5/g== + dependencies: + co "^4.6.0" + es6-promisify "^6.0.2" + globby "^10.0.1" + istextorbinary "^2.5.1" + lodash "^4.17.15" + request-promise-core@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.3.tgz#e9a3c081b51380dfea677336061fea879a829ee9" @@ -18772,11 +18829,6 @@ rollup-plugin-cleaner@^1.0.0: dependencies: rimraf "^2.6.3" -rollup-plugin-command@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/rollup-plugin-command/-/rollup-plugin-command-1.1.3.tgz#c42ac0a6313560f2184e9c64c431f0a639373ffe" - integrity sha512-9nIcP5mgVYWGU7x/6ufTgtqI4vl5vvsYs6fTTil91NX53EIPcim42FXmq1TPdZRFJbUM1ikrg05clahPxObL1g== - rollup-plugin-commonjs@^10.1.0: version "10.1.0" resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz#417af3b54503878e084d127adf4d1caf8beb86fb" @@ -20481,6 +20533,11 @@ text-table@0.2.0, text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= +textextensions@^2.5.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/textextensions/-/textextensions-2.6.0.tgz#d7e4ab13fe54e32e08873be40d51b74229b00fc4" + integrity sha512-49WtAWS+tcsy93dRt6P0P3AMD2m5PvXRhuEA0kaXos5ZLlujtYmpmFsB+QvWUSxE1ZsstmYXfQ7L40+EcQgpAQ== + thenify-all@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726"