Skip to content

Commit

Permalink
chore(deps): bump d3 and @types/d3 to 7.4 (#4081)
Browse files Browse the repository at this point in the history
* chore(deps): bump d3 and @types/d3

Bumps [d3](https://github.com/d3/d3) and [@types/d3](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/d3). These dependencies needed to be updated together.

Updates `d3` from 6.7.0 to 7.4.4
- [Release notes](https://github.com/d3/d3/releases)
- [Changelog](https://github.com/d3/d3/blob/main/CHANGES.md)
- [Commits](d3/d3@v6.7.0...v7.4.4)

Updates `@types/d3` from 6.7.5 to 7.4.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/d3)

---
updated-dependencies:
- dependency-name: d3
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: "@types/d3"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update package.json

* feat: add support for jest

* chore: upgrade recharts

* test: update snapshot

* fix: stop ignore transform node_modules

* chore: udpate changelog

* test: update snap

* chore: move to option 2

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jean-Michel FRANCOIS <jmfrancois@talend.com>
  • Loading branch information
dependabot[bot] and jmfrancois committed Jul 28, 2022
1 parent 5e01487 commit b02eb9e
Show file tree
Hide file tree
Showing 7 changed files with 466 additions and 397 deletions.
7 changes: 7 additions & 0 deletions .changeset/pretty-bugs-drive.md
@@ -0,0 +1,7 @@
---
'@talend/react-components': minor
'@talend/react-dataviz': minor
'@talend/react-flow-designer': minor
---

feat: upgrade d3 to 7
7 changes: 7 additions & 0 deletions .changeset/smooth-geckos-wonder.md
@@ -0,0 +1,7 @@
---
'@talend/scripts-config-jest': minor
---

feat: transpile node_modules

Since d3 7.x and its dependencies use es6 as main entry in package.json, we need this because jest support of [ECMAPScriptModules](https://github.com/facebook/jest/blob/64de4d7361367fd711a231d25c37f3be89564264/docs/ECMAScriptModules.md) is experiemental
6 changes: 3 additions & 3 deletions packages/components/package.json
@@ -1,6 +1,6 @@
{
"name": "@talend/react-components",
"description": "Set of react widgets.",
"description": "Set of react components.",
"main": "lib/index.js",
"mainSrc": "src/index.js",
"license": "Apache-2.0",
Expand Down Expand Up @@ -41,7 +41,7 @@
"@talend/utils": "^2.4.0",
"ally.js": "^1.4.1",
"classnames": "^2.3.1",
"d3": "^6.7.0",
"d3": "^7.4.4",
"date-fns": "^1.30.1",
"focus-outline-manager": "^1.0.2",
"immutable": "^3.8.2",
Expand All @@ -62,7 +62,7 @@
"react-use": "^17.4.0",
"react-virtualized": "^9.22.3",
"reactour": "^1.18.7",
"recharts": "^2.1.12",
"recharts": "^2.1.13",
"simplebar": "^5.3.8",
"simplebar-react": "^2.4.1",
"styled-components": "^5.3.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/dataviz/package.json
Expand Up @@ -41,11 +41,11 @@
"@talend/react-components": "^7.5.0",
"@talend/design-tokens": "^2.7.0",
"classnames": "^2.3.1",
"d3": "^6.7.0",
"d3": "^7.4.4",
"date-fns": "^2.28.0",
"geojson": "^0.5.0",
"lodash": "^4.17.21",
"recharts": "^2.1.12",
"recharts": "^2.1.13",
"topojson-client": "^3.1.0"
},
"devDependencies": {
Expand All @@ -58,7 +58,7 @@
"@talend/scripts-preset-react-lib": "^12.0.1",
"@testing-library/react": "^12.1.5",
"@types/classnames": "^2.3.1",
"@types/d3": "^6.7.5",
"@types/d3": "^7.4.0",
"@types/enzyme": "^3.10.12",
"@types/geojson": "^7946.0.10",
"@types/lodash": "^4.14.182",
Expand Down
4 changes: 2 additions & 2 deletions packages/flow-designer/package.json
Expand Up @@ -22,7 +22,7 @@
"@talend/scripts-config-jest": "^11.1.0",
"@talend/scripts-core": "^12.0.0",
"@talend/scripts-preset-react-lib": "^12.0.1",
"@types/d3": "^6.7.5",
"@types/d3": "^7.4.0",
"@types/enzyme": "^3.10.12",
"@types/invariant": "^2.2.35",
"@types/lodash": "^4.14.182",
Expand Down Expand Up @@ -57,7 +57,7 @@
},
"dependencies": {
"classnames": "^2.3.1",
"d3": "^6.7.0",
"d3": "^7.4.4",
"invariant": "^2.2.4",
"prop-types": "^15.8.1",
"react-immutable-proptypes": "^2.2.0"
Expand Down
54 changes: 51 additions & 3 deletions tools/scripts-config-jest/jest.config.js
@@ -1,20 +1,68 @@
const path = require('path');
const { getBabelConfigPath } = require('@talend/scripts-config-babel/babel-resolver');
// took from d3/package.json
const d3Pkgs = [
'd3',
'd3-array',
'd3-axis',
'd3-brush',
'd3-chord',
'd3-color',
'd3-contour',
'd3-delaunay',
'd3-dispatch',
'd3-drag',
'd3-dsv',
'd3-ease',
'd3-fetch',
'd3-force',
'd3-format',
'd3-geo',
'd3-hierarchy',
'd3-interpolate',
'd3-path',
'd3-polygon',
'd3-quadtree',
'd3-random',
'd3-scale',
'd3-scale-chromatic',
'd3-selection',
'd3-shape',
'd3-time',
'd3-time-format',
'd3-timer',
'd3-transition',
'd3-zoom',
];

// option 1 map module to an bundled version of the package which is es5
const moduleNameMapper = d3Pkgs.reduce((acc, pkg) => {
acc[`^${pkg}$`] = path.join(require.resolve(pkg), `../../dist/${pkg}.min.js`);
return acc;
}, {});

module.exports = {
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|woff|woff2)$': path.join(__dirname, 'file-mock.js'),
'^.+\\.(css|scss)$': path.join(__dirname, 'style-mock.js'),
// option 1
// ...moduleNameMapper
},
rootDir: process.cwd(),
setupFilesAfterEnv: [path.join(__dirname, 'test-setup.js')],
testEnvironment: 'jest-environment-jsdom-global',
testRegex: 'src/.*\\.test.(js|ts|tsx)$',
transform: {
'^.+\\.jsx?$': ['babel-jest', { configFile: getBabelConfigPath() }],
'^.+\\.mjs?$': ['babel-jest', { configFile: getBabelConfigPath() }],
'^.+\\.tsx?$': ['babel-jest', { configFile: getBabelConfigPath() }],
// match mjs js jsx ts tsx
'^.+\\.m?[jt]sx?$': ['babel-jest', { configFile: getBabelConfigPath() }],
},
// stop ignore node_modules transform since d3 and others start to put es6 as main of packages
transformIgnorePatterns: [
// option 2, stop ignore transform on es6 packages
`/node_modules/(?!${d3Pkgs.join('|')}|internmap|d3-delaunay|delaunator|robust-predicates)`,
// option 3, stop ignore transform on all node_modules
// `/node_modules/(?!.*)`,
],
snapshotSerializers: ['jest-serializer-html'],
modulePathIgnorePatterns: ['<rootDir>/dist/cdn'],
};

0 comments on commit b02eb9e

Please sign in to comment.