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

[DataGrid] Fix typings and packages assets #339

Merged
merged 12 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"packages/x-license",
"packages/grid/data-grid",
"packages/grid/x-grid",
"packages/grid/x-grid-data-generator"
"packages/x-grid-data-generator"
],
"publishDirectory": {
"@material-ui/x-license": "packages/x-license",
"@material-ui/data-grid": "packages/grid/data-grid",
"@material-ui/x-grid": "packages/grid/x-grid",
"@material-ui/x-grid-data-generator": "packages/grid/x-grid-data-generator"
"@material-ui/x-grid-data-generator": "packages/x-grid-data-generator"
},
"sandboxes": [
"new",
Expand Down
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
/docs/export
/lerna.json
/packages/demo-app/public/static-data
/packages/grid/lib/lodash
/packages/grid/x-grid-modules/lib/autosizer
/packages/grid/x-grid-modules/lib/lodash
lib
CHANGELOG.md
dist
node_modules
3 changes: 1 addition & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ if (process.env.BABEL_ENV === 'es') {

const defaultAlias = {
'@material-ui/data-grid': './packages/grid/data-grid/src',
'@material-ui/x-grid-data-generator': './packages/grid/x-grid-data-generator/src',
'@material-ui/x-grid-modules': './packages/grid/x-grid-modules/src',
'@material-ui/x-grid-data-generator': './packages/x-grid-data-generator/src',
'@material-ui/x-grid': './packages/grid/x-grid/src',
'@material-ui/x-license': './packages/x-license/src',
};
Expand Down
3 changes: 1 addition & 2 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ function resolvePath(sourcePath, currentFile, opts) {

const alias = {
'@material-ui/data-grid': '../packages/grid/data-grid/src',
'@material-ui/x-grid-data-generator': '../packages/grid/x-grid-data-generator/src',
'@material-ui/x-grid-modules': '../packages/grid/x-grid-modules/src',
'@material-ui/x-grid-data-generator': '../packages/x-grid-data-generator/src',
'@material-ui/x-grid': '../packages/grid/x-grid/src',
'@material-ui/x-license': '../packages/x-license/src',
// Help in the event npm and git are significantly desynchronized.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"jsonlint": "node scripts/jsonlint.js",
"typescript": "lerna run typescript --parallel",
"build:codesandbox": "yarn lerna:build",
"lerna:build": "cd packages/x-license && yarn build && cd ../grid/x-grid-modules && yarn build && cd ../data-grid && yarn build && cd ../x-grid && yarn build && cd ../x-grid-data-generator && yarn build",
"lerna:build": "cd packages/x-license && yarn build && cd ../grid && yarn build && cd ../x-grid-data-generator && yarn build",
"lerna:publish": "lerna publish"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/grid/_modules_/grid/components/autosizer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AutoSizer from '../lib/autosizer';

export const AutoSizerWrapper = AutoSizer;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _debounce from '../../lib/lodash/debounce';
import isEqual from '../../lib/lodash/isEqual';
import _debounce from '../lib/lodash/debounce';
import isEqual from '../lib/lodash/isEqual';

export { isEqual };

Expand Down
1 change: 1 addition & 0 deletions packages/grid/_modules_/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './grid';
6 changes: 1 addition & 5 deletions packages/grid/data-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"
],
Expand All @@ -26,19 +26,15 @@
],
"scripts": {
"precommit": "npm run lint",
"build": "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",
"test": "../../../node_modules/.bin/jest --config jest.config.js",
"typescript": "tsc -p tsconfig.json"
},
"dependencies": {
"prop-types": "^15.7.2",
"tslib": "^2.0.0"
},
"devDependencies": {
"@material-ui/x-grid-modules": "^4.0.0-alpha.2",
"@rollup/plugin-node-resolve": "^8.0.1",
"rollup": "^2.6.1",
"rollup-plugin-cleaner": "^1.0.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/grid/data-grid/src/DataGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { chainPropTypes } from '@material-ui/utils';
import { GridComponent, GridComponentProps, classnames } from '@material-ui/x-grid-modules';
import { GridComponent, GridComponentProps, classnames } from '../../_modules_/grid';

const chainPropTypes = require('@material-ui/utils').chainPropTypes;

const FORCED_PROPS: Partial<GridComponentProps> = {
disableColumnResize: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/data-grid/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from '@material-ui/x-grid-modules';
export * from '../../_modules_';
export * from './DataGrid';
22 changes: 0 additions & 22 deletions packages/grid/data-grid/tsconfig.build.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
preset: 'ts-jest',
rootDir: './',
rootDir: './_modules_',
testEnvironment: 'node',
transform: {
'^.+\\.(t|j)sx?$': 'ts-jest',
Expand Down
15 changes: 15 additions & 0 deletions packages/grid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@material-ui/grid",
"version": "4.0.0-alpha.2",
"private": true,
"scripts": {
"build:data-grid": "rollup --c",
"build:x": "rollup --config rollup.x-grid.config.js",
"build": "rollup --c && rollup --config rollup.x-grid.config.js",
"start": "rollup -cw",
"start:x": "rollup -w --config rollup.x-grid.config.js",
"test:modules": "../../node_modules/.bin/jest --config jest.config.js",
"lint": "../../../node_modules/.bin/tsc --noEmit && eslint 'src/**/*.{ts,tsx}' --quiet --fix -c ../../../.eslintrc.js && npm run lint:css",
"lint:css": "stylelint 'src/**/*.{ts,tsx}' ../../../.stylelintrc.js"
}
}
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
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';
import pkg from './data-grid/package.json';

// dev build if watching, prod build if not
const production = !process.env.ROLLUP_WATCH;
export default [
{
input: 'src/index.ts',
input: './data-grid/src/index.ts',
output: [
{
file: 'dist/index-esm.js',
file: './data-grid/dist/index-esm.js',
format: 'esm',
sourcemap: !production,
},
{
file: 'dist/index-cjs.js',
file: './data-grid/dist/index-cjs.js',
format: 'cjs',
sourcemap: !production,
},
],

external: [...Object.keys(pkg.peerDependencies || {})],
plugins: [
resolve({
resolveOnly: [/^@material-ui\/x-.*$/], // we bundle x-license and x-grid-modules
}),
production &&
cleaner({
targets: ['./dist/'],
targets: ['./data-grid/dist/'],
}),
typescript({ tsconfig: 'tsconfig.build.json' }),
typescript({ tsconfig: 'tsconfig.json' }),
Copy link
Member

@oliviertassinari oliviertassinari Sep 23, 2020

Choose a reason for hiding this comment

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

I think that we need two different tsconfig files:

Suggested change
typescript({ tsconfig: 'tsconfig.json' }),
typescript({ tsconfig: 'tsconfig.build.json' }),

One to lint the sources (a.) and a second one to build (b.). For instance, with (a.) we want to lint the end-to-end tests and the TypeScript tests, with (b.) we don't want to build the definitions for them.

Copy link
Member Author

Choose a reason for hiding this comment

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

I understand how the 2 files are used.
Not sure we need the one for linting.

Copy link
Member

@oliviertassinari oliviertassinari Sep 24, 2020

Choose a reason for hiding this comment

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

Why wouldn't we need one for linting? The main reason I see is different include/excludes configuration.

Copy link
Member Author

Choose a reason for hiding this comment

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

because at the root you specify to lint every files with ts js tsx extensions, with no-emit, and it uses the eslint ignore
same inside packages
the only place it is used it's for the yarn typescript command which is just used to check the test as we exclude them in the build

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I wasn't clear. There are two linting stages: eslint and TypeScript. These are complementary. I was referring to the latter.

Copy link
Member

@oliviertassinari oliviertassinari Sep 24, 2020

Choose a reason for hiding this comment

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

From what I know:

  • lint with eslint is configured at the root and ran with a single command (yarn eslint).
  • lint with TypeScript is run in parallel with Lerna and defined in each package (yarn typescript).

Copy link
Member

@oliviertassinari oliviertassinari Sep 24, 2020

Choose a reason for hiding this comment

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

the only place it is used it's for the yarn typescript command which is just used to check the test as we exclude them in the build

yarn typescript tests all the demos of the documentation, all the end-to-end tests, all the type definition tests. Without this command, we would get silent fails (not reported in the CI).

!production && sourceMaps(),
production && terser(),
],
},
{
input: './dist/index.d.ts',
output: [{ file: 'dist/data-grid.d.ts', format: 'es' }],
input: './data-grid/dist/data-grid/src/index.d.ts',
output: [{ file: './data-grid/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(),
production &&
command(
[
`rm -rf ./data-grid/dist/data-grid/`,
`rm -rf ./data-grid/dist/_modules_ `,
`rm -rf ./data-grid/dist/x-grid`,
],
{
exitOnFail: true,
wait: true,
},
),
],
},
];
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
import typescript from 'rollup-plugin-typescript2';
import { generateReleaseInfo } from '@material-ui/x-license';
import replace from '@rollup/plugin-replace';
import typescript from 'rollup-plugin-typescript2';
import cleaner from 'rollup-plugin-cleaner';
import sourceMaps from 'rollup-plugin-sourcemaps';
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';
import pkg from './x-grid/package.json';

// dev build if watching, prod build if not
const production = !process.env.ROLLUP_WATCH;
export default [
{
input: 'src/index.ts',
input: './x-grid/src/index.ts',
output: [
{
file: 'dist/index-esm.js',
file: './x-grid/dist/index-esm.js',
format: 'esm',
sourcemap: !production,
},
{
file: 'dist/index-cjs.js',
file: './x-grid/dist/index-cjs.js',
format: 'cjs',
sourcemap: !production,
},
Expand All @@ -32,28 +31,33 @@ export default [
replace({
__RELEASE_INFO__: generateReleaseInfo(),
}),
resolve({
resolveOnly: [/^@material-ui\/x-.*$/], // we bundle x-license and x-grid-modules
}),
production &&
cleaner({
targets: ['./dist/'],
targets: ['./x-grid/dist/'],
}),
typescript(),
typescript({ tsconfig: 'tsconfig.json' }),
!production && sourceMaps(),
production && terser(),
],
},
{
input: './dist/index.d.ts',
output: [{ file: 'dist/x-grid.d.ts', format: 'es' }],
input: './x-grid/dist/x-grid/src/index.d.ts',
output: [{ file: './x-grid/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(),
production &&
command(
[
`rm -rf ./x-grid/dist/x-grid`,
`rm -rf ./x-grid/dist/_modules_`,
`rm -rf ./x-grid/dist/data-grid`,
],
{
exitOnFail: true,
wait: true,
},
),
],
},
];
28 changes: 28 additions & 0 deletions packages/grid/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"baseUrl": "./",
"declaration": true,
"declarationDir": "./dist",
"module": "es6",
"noImplicitAny": false,
"strict": true,
"outDir": "./dist",
"target": "es6",
"sourceMap": true,

"lib": ["dom", "dom.iterable", "esnext", "ES6"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react",
"types": ["jest", "node"],
"rootDir": "./"
},
"include": ["./data-grid/src", "./x-grid/src", "./_modules_/**/*"],
"exclude": ["__tests__", "**/*.test.ts", "node_modules"]
}
10 changes: 0 additions & 10 deletions packages/grid/x-grid-modules/jest.config.js

This file was deleted.

Loading