Skip to content

Commit

Permalink
feat: files cjs => esm
Browse files Browse the repository at this point in the history
  • Loading branch information
cycgit committed May 13, 2020
1 parent 4904a04 commit 380c53d
Show file tree
Hide file tree
Showing 121 changed files with 2,161 additions and 1,964 deletions.
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@util": ["./src/util/common"]
}
}
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@rollup/plugin-alias": "^3.1.0",
"@rollup/plugin-babel": "^5.0.0",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
Expand Down Expand Up @@ -93,7 +94,7 @@
"lint-fix": "eslint --fix ./",
"prepublishOnly": "npm run build-lib && npm run dist",
"screenshot": "DEBUG=app:* ./bin/screenshot.js",
"test": "jest",
"t2": "jest test/unit/global-spec.js",
"test-unit": "jest test/unit",
"test-bug": "jest test/bug",
"test-live": "DEBUG_MODE=1 jest --watch",
Expand All @@ -110,7 +111,11 @@
"jest": {
"runner": "jest-electron/runner",
"testEnvironment": "jest-electron/environment",
"testRegex": "/test/.*-spec\\.js?$"
"testRegex": "/test/.*-spec\\.js?$",
"verbose": false,
"moduleNameMapper": {
"^@util$": "<rootDir>/src/util/common.js"
}
},
"dependencies": {
"@antv/adjust": "~0.1.1",
Expand Down
15 changes: 11 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { terser } from 'rollup-plugin-terser';
// import { terser } from 'rollup-plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
import alias from '@rollup/plugin-alias';

import commonjs from '@rollup/plugin-commonjs';
const path = require('path');

export default {
input: './src/index-all.js',
output: {
name: 'F2',
file: 'rtest/bundle.js',
format: 'umd',
plugins: [ terser() ]
format: 'umd'
},
plugins: [ resolve(), commonjs() ]
plugins: [ resolve(), commonjs(), alias({
entries: {
'@util': path.resolve(__dirname, 'src/util/common.js')
}
})
]
};
7 changes: 0 additions & 7 deletions rtest/bundle.js

This file was deleted.

6 changes: 4 additions & 2 deletions rtest/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</head>
<body>
<canvas id="container"></canvas>
<script src="./bundle.js"></script>
<!-- <script src="https://gw.alipayobjects.com/os/antv/assets/f2/3.4.2/f2.min.js"></script> -->
<!-- <script src="./bundle.js"></script> -->
<script src="https://gw.alipayobjects.com/os/antv/assets/f2/3.4.2/f2.min.js"></script>
<script>
// cosnole.log(F2)

Expand All @@ -23,6 +23,8 @@
// Step 1: 创建 Chart 对象
const chart = new F2.Chart({
id: 'container',
width: 300,
height: 200,
pixelRatio: window.devicePixelRatio // 指定分辨率
});

Expand Down
9 changes: 5 additions & 4 deletions src/animation/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Animate configuration and register
* @author sima.zhang1990@gmail.com
*/
const Util = require('../util/common');
import { isFunction, deepMix } from '@util';

const defaultAnimationCfg = {
appear: {
duration: 450,
Expand All @@ -29,7 +30,7 @@ const Animate = {
const geomAnimateCfg = this.defaultCfg[geomType];
if (geomAnimateCfg) {
const animation = geomAnimateCfg[animationType];
if (Util.isFunction(animation)) {
if (isFunction(animation)) {
return animation(coord);
}
}
Expand All @@ -39,7 +40,7 @@ const Animate = {
const defaultCfg = defaultAnimationCfg[animationType];
const geomConfig = this.defaultCfg[geomType];
if (geomConfig && geomConfig.cfg && geomConfig.cfg[animationType]) {
return Util.deepMix({}, defaultCfg, geomConfig.cfg[animationType]);
return deepMix({}, defaultCfg, geomConfig.cfg[animationType]);
}
return defaultCfg;
},
Expand All @@ -51,4 +52,4 @@ const Animate = {
}
};

module.exports = Animate;
export default Animate;
Loading

0 comments on commit 380c53d

Please sign in to comment.