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

Add victory-vendor package for d3 dependencies #2204

Merged
merged 76 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
2093482
Add node script
ryan-roemer Apr 21, 2022
c7f7406
Add more tests
ryan-roemer Apr 21, 2022
ee9273c
WIP: Start working on basics of vendoring.
ryan-roemer Apr 21, 2022
1963e22
Start consuming victory-vendor
ryan-roemer Apr 21, 2022
260267b
Remove old file
ryan-roemer Apr 21, 2022
c327bc3
Clean up
ryan-roemer Apr 21, 2022
deee3a4
Add LICENSE
ryan-roemer Apr 22, 2022
6f85d7b
Start namespacing libraries
ryan-roemer Apr 22, 2022
5306c6b
Add more to victory-vendor
ryan-roemer Apr 22, 2022
2f5fcb0
WIP: Build works, test / webpack doesn't
ryan-roemer Apr 22, 2022
b89d8b0
WIP: Get karma tests working
ryan-roemer Apr 23, 2022
de946e5
Add nohoist for victory-vendor
ryan-roemer Apr 23, 2022
926e253
WIP: Build script
ryan-roemer Apr 25, 2022
2ba67c0
WIP: Add vendor build process for all libraries
ryan-roemer Apr 25, 2022
681758b
Tests now work aside from 1
ryan-roemer Apr 25, 2022
eada782
Remove unneeded alias references.
ryan-roemer Apr 25, 2022
15d709f
Refactor imports
ryan-roemer Apr 25, 2022
54c2236
Remove unneeded d3 things
ryan-roemer Apr 25, 2022
e17346c
Remove unused fields in vendor pkg
ryan-roemer Apr 25, 2022
1aafacf
Remove unused module-resolver config
ryan-roemer Apr 25, 2022
1060a0e
Remove src references
ryan-roemer Apr 25, 2022
7562a3b
Contnue removing src imports
ryan-roemer Apr 25, 2022
0e4af87
More src removal
ryan-roemer Apr 25, 2022
5a8a651
More import work
ryan-roemer Apr 25, 2022
f1686de
Add root CJS index for Jest
ryan-roemer Apr 25, 2022
03e887d
Remove last src imports in tests
ryan-roemer Apr 25, 2022
f9de796
Add more changes
ryan-roemer Apr 25, 2022
e15c29d
Add vendor nps script
ryan-roemer Apr 25, 2022
ae5bd4e
Add node tests
ryan-roemer Apr 26, 2022
1fed5fd
Fix karma coverage task
ryan-roemer Apr 26, 2022
f7f733b
Fix watch script for vendor.
ryan-roemer Apr 26, 2022
68f46c3
Comment
ryan-roemer Apr 26, 2022
05dae53
Various PR fixes
ryan-roemer Apr 26, 2022
1280514
WIP: Fixing lint stuff
ryan-roemer Apr 27, 2022
9c354c7
Remove root d3-voronoi import and just re-export from app
ryan-roemer Apr 27, 2022
6998954
Add license info for victory-vendor
ryan-roemer Apr 27, 2022
2924291
Fix lint.vendor
ryan-roemer Apr 27, 2022
f7c2039
Lint should work now
ryan-roemer Apr 27, 2022
bec90ec
Add lint.docs to default task
ryan-roemer Apr 27, 2022
3f775c5
Add format.fix
ryan-roemer Apr 28, 2022
e0db5dc
Add lint.fix and docs. Skip docs for now
ryan-roemer Apr 28, 2022
0e30f71
Switch to older version of promise require
ryan-roemer Apr 28, 2022
e8f1f9a
Fix package-scripts
ryan-roemer Apr 28, 2022
919df45
Remove unused karma stuff
ryan-roemer Apr 28, 2022
351ad84
Update karma watch
ryan-roemer Apr 28, 2022
92c7f83
Remove unneeded packages alias and remove all code inclusion in Karma
ryan-roemer Apr 28, 2022
3138788
Add lint.config and actually lint our configuration.
ryan-roemer Apr 28, 2022
6109aed
Add concurrency gates to some parallel commands
ryan-roemer Apr 28, 2022
6dc9696
Lint fixes
ryan-roemer Apr 28, 2022
248b9f3
Fix scripts
ryan-roemer Apr 28, 2022
4f2a7d3
Remove unneeded alias
ryan-roemer Apr 28, 2022
8f4e80b
Remove TS alias
ryan-roemer Apr 28, 2022
b8e1655
Remove comments for manual babelrcs
ryan-roemer Apr 29, 2022
84e8815
Debugging notes
ryan-roemer May 2, 2022
08a45b0
Add fix for voronoi
ryan-roemer May 2, 2022
bba2752
WIP: Working on getType()
ryan-roemer May 3, 2022
28d2eea
Tests should pass
ryan-roemer May 3, 2022
d937dc4
Cleanup
ryan-roemer May 3, 2022
5f60e9a
Merge upstream
ryan-roemer May 4, 2022
fab0c6c
Update jest code
ryan-roemer May 4, 2022
95962ae
Get storybook working.
ryan-roemer May 4, 2022
dda97c3
Fix imports for storybook
ryan-roemer May 4, 2022
3ec5d68
Cleanup
ryan-roemer May 4, 2022
cec4e61
Write docs script to get react-static build failure to error in terminal
ryan-roemer May 5, 2022
b23db42
Revert imports for victory-vendor in docs
ryan-roemer May 5, 2022
4413a6a
Get docs build working again.
ryan-roemer May 5, 2022
6f9dd64
Prettier
ryan-roemer May 5, 2022
6325007
Merge upstream
ryan-roemer May 6, 2022
3e3c2c5
Merge branch 'main' into chore/vendor-d3
ryan-roemer May 10, 2022
ec078d5
Uncomment pow-sqrt duck type
May 10, 2022
37eb2c7
Merge branch 'chore/vendor-d3' of github.com:FormidableLabs/victory i…
May 10, 2022
4e486ea
Resolve merge conflicts
May 10, 2022
733aff1
Revert "Uncomment pow-sqrt duck type"
May 10, 2022
d67f4e4
Fix jest
ryan-roemer May 10, 2022
96806f9
Add comment on d3 tickFormat
May 10, 2022
38fea26
Merge branch 'chore/vendor-d3' of github.com:FormidableLabs/victory i…
May 10, 2022
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
26 changes: 9 additions & 17 deletions .babelrc → .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": ["@babel/react"],
"plugins": [
module.exports = {
presets: ["@babel/preset-react"],
plugins: [
"lodash",
"@babel/proposal-class-properties",
"@babel/transform-arrow-functions",
Expand All @@ -15,25 +15,17 @@
"@babel/proposal-object-rest-spread",
"@babel/plugin-proposal-export-namespace-from"
],
"env": {
"commonjs": {
"plugins": [
env: {
commonjs: {
plugins: [
[
"@babel/transform-modules-commonjs",
{
"strict": false,
"allowTopLevelThis": true
}
],
[
"module-resolver",
{
"alias": {
"^victory-(.+)/es/(.+)": "^victory-\\1/lib/\\2"
}
strict: false,
allowTopLevelThis: true
}
]
]
}
}
}
};
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
node_modules
config
package-scripts.js
storybook-static
coverage
dist
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
coverage
dist
lib
lib-vendor
es
packages/victory-vendor/d3-*.js
node_modules
npm-debug.log*
lerna-debug.log*
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Victory Changelog

## UNRELEASED

* Vendor in d3 libraries to new package `victory-vendor` and upgrade. Our CommonJS path now uses transpiled versions of the `d3-*` libraries while our ESM path continues to use the real underlying dependencies.
* Update our tests to only refer to _built_ versions of our libraries (in the past there was a mix of source and built). This means Karma uses the ESM version of libraries while Jest uses the CommonJS versions.
* Added very basic Node.js tests to catch future ESM issues.
* Switch all relative/prefixed import paths to be just `import <name> from "victory-<pkg>"`.
* Update various dependencies.

## 36.3.2 (2022-04-14)
* Added functionality to be able to pass user props to components. Safe… by @dlcartright in https://github.com/FormidableLabs/victory/pull/2151
* Bump moment from 2.29.1 to 2.29.2 by @dependabot in https://github.com/FormidableLabs/victory/pull/2186
Expand Down
56 changes: 43 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,72 @@ Victory uses [`nps`](https://github.com/kentcdodds/nps) to organize package scri

Clone this repo:

```console
```sh
$ git clone https://github.com/FormidableLabs/victory.git
$ cd victory
```

Use [Yarn](https://yarnpkg.com/) to install dependencies:

```console
```sh
$ yarn install
```

Run a development server and check out the demos. This command will also build and watch `lib/` and `es/` directories in all packages, so your demos will always be in sync with code changes.

```console
```sh
$ yarn start
```

running this command will serve demo pages at http://localhost:3000/ and tests at http://localhost:3001/test/client/test.html

As a useful tip if you're working in just one package in the monorepo, you can rebuild just that package:

```sh
$ lerna exec --scope <package name> -- yarn nps build-libs
$ lerna exec --scope victory-core -- yarn nps build-libs
```

## Checks, Tests

When running a development server, tests will be served automatically at http://localhost:3001/test/client/test.html

Tests may also be run in the terminal with:

```console
```sh
# Build and run all tests.
$ yarn nps test

# Run just Karma tests (packages must be already built).
$ yarn nps karma
$ KARMA_CAPTURE_CONSOLE=true yarn nps karma # Same, but enable console logging in CLI
```

If your terminal is under a proxy, you should turn off the proxy, or ChromeHeadless will not start properly.

If you are debugging tests with Karma, it's usually easier to debug in a real browser. An example workflow:

```sh
# In one terminal run a watch on library files
$ yarn nps watch

# In another terminal the browser Karma server
$ yarn nps server.test

# Open a browser
$ open http://localhost:3001/test/client/test.html
```

Victory uses eslint and prettier to maintain code style consistency. Before creating a pull request, please lint and format your changes with the following commands:

```console
$ yarn nps lint
$ yarn nps format
```sh
# Lint
$ yarn nps lint # check
$ lerna exec --scope <pkg name> -- yarn nps lint.fix # fix specific package

# Prettier
$ yarn nps format.ci # check
$ yarn nps format.fix # fix
```

## Visual Tests
Expand All @@ -74,13 +104,13 @@ Victory relies heavily on visual regression testing with [Storybook](https://sto

Write visual tests for new features by adding them in the `stories` directory. Run storybooks and check out changes. Storybooks are served from http://localhost:6006/

```console
```sh
$ yarn storybook
```

[Chromatic](https://www.chromaticqa.com/) provides automated visual testing. All internal PRs will trigger a new Chromatic build, which will be displayed along with CI status. Chromatic builds for Victory may be viewed in more detail here: https://www.chromaticqa.com/builds?appId=5b4acf7c54c0490024d5980b. Chromatic requires a secret app code to run, so PRs from external contributors will not automatically trigger a Chromatic build. For this reason, changes from external contributors will be checked out and opened as separate PRs so Chromatic may be used to verify any changes. Developers with access to the secret app code may also trigger a chromatic build manually with:

```console
```sh
$ yarn chromatic
```

Expand All @@ -90,28 +120,28 @@ Victory uses [Lerna](https://lerna.js.org/) to automate versioning and publishin

Each package must contain the following `version` script `package.json`:

```
```js
"scripts": {
"version": "nps build-libs && nps build-dists",
}
```

Before versioning, we run `lerna bootstrap` and `link-parent-bin` to ensure that each individual package has the `devDependencies` it needs to run its `version` script. Pre version checks are run _once_ for all packages, and are defined in the root directory `package.json`

```
```js
"preversion": "lerna bootstrap && link-parent-bin && nps check"
```

The following commands will let you try a version without publishing or creating git commits:

```console
```sh
// This command bumps versions, runs checks, builds libs. No git commits will be made, and nothing will be published. `package.json` files in all packages will be altered, so be careful to clean up afterwards. This command will only run all pre-version scripts if there are committed changes to packages, so creating a test commit before running this command will typically be necessary.
$ nps lerna-dry-run
```

To publish a package _for real_

```console
```sh
$ lerna publish
```

Expand Down
5 changes: 5 additions & 0 deletions config/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": ["formidable/configurations/es6-node", "prettier"],
"rules": {},
"globals": {}
}
6 changes: 3 additions & 3 deletions config/karma/karma.conf.coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*
* This configuration is the same as basic one-shot version, just with coverage.
*/
var path = require("path");
var webpackCovCfg = require("../webpack/webpack.config.coverage");
const path = require("path");
const webpackCovCfg = require("../webpack/webpack.config.coverage");

// Replace with `__dirname` if using in project root.
var ROOT = process.cwd();
const ROOT = process.cwd();

module.exports = function (config) {
/* eslint-disable global-require */
Expand Down
15 changes: 3 additions & 12 deletions config/karma/karma.conf.dev.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
"use strict";
var path = require("path");
const path = require("path");

var MAIN_PATH = path.join(process.cwd(), "test/client/main.js");
var POLYFILL_PATH = path.join(
path.dirname(require.resolve("core-js/package.json")),
"es6/**/*.js"
);
var PREPROCESSORS = {};
const MAIN_PATH = path.resolve("test/client/main.js");
const PREPROCESSORS = {};
PREPROCESSORS[MAIN_PATH] = ["webpack"];
PREPROCESSORS[POLYFILL_PATH] = ["webpack"];

/*
* Karma Configuration: "dev" version.
Expand Down Expand Up @@ -36,10 +31,6 @@ module.exports = function (config) {
// Sinon has issues with webpack. Do global include.
require.resolve("sinon/pkg/sinon"),

// Polyfills for PhantomJS in React 16.
require.resolve("core-js/es6/map"),
require.resolve("core-js/es6/set"),

// Test bundle (must be created via `npm run dev|hot|server-test`)
"http://127.0.0.1:3001/assets/main.js"
],
Expand Down
19 changes: 5 additions & 14 deletions config/karma/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@
* the test files one-off for just a single run. This is appropriate for a
* CI environment or if you're not otherwise running `npm run dev|hot`.
*/
var path = require("path");
var webpack = require("webpack");
var webpackCfg = require("../webpack/webpack.config.test");
const path = require("path");
const webpack = require("webpack");
const webpackCfg = require("../webpack/webpack.config.test");

var MAIN_PATH = path.join(process.cwd(), "test/client/main.js");
var POLYFILL_PATH = path.join(
path.dirname(require.resolve("core-js/package.json")),
"es6/**/*.js"
);
var PREPROCESSORS = {};
const MAIN_PATH = path.resolve("test/client/main.js");
const PREPROCESSORS = {};
PREPROCESSORS[MAIN_PATH] = ["webpack"];
PREPROCESSORS[POLYFILL_PATH] = ["webpack"];

module.exports = function (config) {
/* eslint-disable global-require */
Expand All @@ -33,10 +28,6 @@ module.exports = function (config) {
// Sinon has issues with webpack. Do global include.
require.resolve("sinon/pkg/sinon"),

// Polyfills for PhantomJS in React 16.
require.resolve("core-js/es6/map"),
require.resolve("core-js/es6/set"),

// Test bundle (created via local webpack-dev-server in this config).
MAIN_PATH
],
Expand Down
25 changes: 13 additions & 12 deletions config/webpack/demo/webpack.config.dev-ts.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
"use strict";

var path = require("path");
var glob = require("glob");
var LodashModuleReplacementPlugin = require("lodash-webpack-plugin");
const path = require("path");
const glob = require("glob");
const LodashModuleReplacementPlugin = require("lodash-webpack-plugin");

var ROOT = process.cwd();
var PACKAGES = glob.sync("packages/*/src", { root: ROOT });
var FILES = PACKAGES.map(function (p) {
const ROOT = process.cwd();
const PACKAGES = glob.sync("packages/*/src", { root: ROOT });
const FILES = PACKAGES.map(function (p) {
return path.join(ROOT, p);
});
var DEMO = path.resolve("demo");
var WDS_PORT = 3000;
const DEMO = path.resolve("demo");
const WDS_PORT = 3000;

module.exports = {
mode: "development",
resolve: {
alias: {
"@packages": path.resolve("packages")
},
extensions: [".ts", ".tsx", ".js", ".json"]
},
entry: "./demo/ts/app.tsx",
Expand Down Expand Up @@ -45,7 +42,11 @@ module.exports = {
// Use include specifically of our sources.
// Do _not_ use an `exclude` here.
include: FILES,
loader: "babel-loader"
use: {
loader: "babel-loader",
// eslint-disable-next-line global-require
options: require("../../../.babelrc.js")
}
}
]
},
Expand Down
27 changes: 13 additions & 14 deletions config/webpack/demo/webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
"use strict";

var path = require("path");
var glob = require("glob");
var LodashModuleReplacementPlugin = require("lodash-webpack-plugin");
const path = require("path");
const glob = require("glob");
const LodashModuleReplacementPlugin = require("lodash-webpack-plugin");

var ROOT = process.cwd();
var PACKAGES = glob.sync("packages/*/src", { root: ROOT });
var FILES = PACKAGES.map(function (p) {
const ROOT = process.cwd();
const PACKAGES = glob.sync("packages/*/src", { root: ROOT });
const FILES = PACKAGES.map(function (p) {
return path.join(ROOT, p);
});
var DEMO = path.resolve("demo");
var WDS_PORT = 3000;
const DEMO = path.resolve("demo");
const WDS_PORT = 3000;

module.exports = {
mode: "development",
resolve: {
alias: {
Packages: path.resolve("packages")
}
},

devServer: {
port: WDS_PORT,
Expand Down Expand Up @@ -50,7 +45,11 @@ module.exports = {
// Use include specifically of our sources.
// Do _not_ use an `exclude` here.
include: FILES.concat([path.join(DEMO, "js")]),
loader: "babel-loader"
use: {
loader: "babel-loader",
// eslint-disable-next-line global-require
options: require("../../../.babelrc.js")
}
}
]
},
Expand Down
8 changes: 4 additions & 4 deletions config/webpack/demo/webpack.config.hot.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict";

var _ = require("lodash");
var base = require("./webpack.config.dev");
const _ = require("lodash");
const base = require("./webpack.config.dev");

// Clone our own module object.
var mod = _.cloneDeep(base.module);
var firstLoader = mod.rules[0]; // eslint-disable-line no-magic-numbers
const mod = _.cloneDeep(base.module);
const firstLoader = mod.rules[0]; // eslint-disable-line no-magic-numbers

// Update rules array. First loader needs react-hot-loader.
firstLoader.rules = [require.resolve("react-hot-loader")]
Expand Down
Loading