Skip to content

Commit

Permalink
chore: split lib for demand loading
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed Aug 11, 2023
1 parent 40cc5b6 commit 8b77a29
Show file tree
Hide file tree
Showing 45 changed files with 881 additions and 174 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ coverage

# Bundle visualizer
stats.html
**/stats.html

# Snapshots error images
__tests__/integration/snapshots/**/*-actual.*
Expand All @@ -36,5 +37,7 @@ site/.dumi/tmp-production
# Editor
.vscode

# Bundle analyzer
analyse.html

# Other
!/src/lib
!/__tests__/unit/lib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/static/windVectorWind.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions __tests__/integration/utils/renderSpec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Canvas } from '@antv/g';
import { createCanvas } from 'canvas';
import { G2Context, G2Spec, createLibrary, render } from '../../../src';
import { G2Context, G2Spec, stdlib, render } from '../../../src';
import { renderToMountedElement } from '../../utils/renderToMountedElement';
import { createNodeGCanvas } from './createNodeGCanvas';

Expand All @@ -15,7 +15,7 @@ export async function renderSpec(
const renderFunction = mounted ? renderToMountedElement : render;
const options = preprocess({ ...raw, width, height });
context.canvas = gCanvas;
context.library = createLibrary();
context.library = stdlib();
context.createCanvas = () => {
// The width attribute defaults to 300, and the height attribute defaults to 150.
// @see https://stackoverflow.com/a/12019582
Expand Down
4 changes: 2 additions & 2 deletions __tests__/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Plugin as ControlPlugin } from '@antv/g-plugin-control';
import { Plugin as ThreeDPlugin } from '@antv/g-plugin-3d';
import { Renderer as SVGRenderer } from '@antv/g-svg';
import { Renderer as WebGLRenderer } from '@antv/g-webgl';
import { createLibrary, render } from '../src';
import { stdlib, render } from '../src';
import { renderToMountedElement } from './utils/renderToMountedElement';
import * as statics from './plots/static';
import * as interactions from './plots/interaction';
Expand Down Expand Up @@ -169,7 +169,7 @@ function createSpecRender(object) {
const node = renderChart(
{ theme: 'classic', ...options },
// @ts-ignore
{ canvas, library: createLibrary() },
{ canvas, library: stdlib() },
() => after?.(),
);

Expand Down
19 changes: 0 additions & 19 deletions __tests__/treeshaking/main.ts

This file was deleted.

4 changes: 2 additions & 2 deletions __tests__/unit/api/chart.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Canvas } from '@antv/g';
import { Renderer as SVGRenderer } from '@antv/g-svg';
import { Chart, createLibrary, ChartEvent } from '../../../src';
import { Chart, stdlib, ChartEvent } from '../../../src';

const TEST_OPTIONS = {
type: 'interval',
Expand Down Expand Up @@ -344,7 +344,7 @@ describe('Chart', () => {

const context = chart.getContext();
expect(context.canvas).toBeUndefined();
expect(context.library).toEqual(createLibrary());
expect(context.library).toEqual(stdlib());
chart.render();
expect(context.canvas).toBeInstanceOf(Canvas);
});
Expand Down
Loading

0 comments on commit 8b77a29

Please sign in to comment.