README
简介
对 openlayer 操作 arcgis 的封装。
开发环境
JavaScript 与 TypeScript 代码的打包的基础环境。
- rollup 打包 es/cjs 模块
- eslint 校验代码
- babel 编译 es6+/ts 代码
- karma-webpack/jasmine 单元测试
目录
|- build 进行生产的配置文件
|- alias.js 路径别名配置
|- build.js 打包脚本
|- config.js 打包配置
|- rollup.config.js rollup 基本配置
|- dist 打包输出
|- *.common.js commonjs 模块
|- *.esm.js es 模块
|- src 源文件
|- stat 包体积分析(html直接打开)
|- test 测试
|- unit 单元测试
|- modules 所有的测试模块
|- index.js 测试模块的入口文件
|- karma.config.js karma 配置文件
|- types ts 类型声明文件
|- .editorconfig 编辑器配置文件
|- .eslintignore eslint 忽略目录配置文件
|- .eslintrc.js eslint 配置文件
|- babel.config.js babel 配置文件
API
注册投影坐标系
export declare type ProjectionRegisterResult = {
code: string;
bbox: number[];
unit: string;
proj4: string;
area: string;
name: string;
}[];
/**
* 注册 projection
* 通过在线查询获取 proj4 值
* @link https://epsg.io
* @param code 例如:4523/4990
*/
export declare function projectionRegister(
code: string | number
): Promise<ProjectionRegisterResult>;
/**
* 批量注册 projection
* @link https://epsg.io
* @param codes 例如:[4523,4990]
*/
export declare function projectionRegisterMultiple(
codes: (string | number)[]
): Promise<ProjectionRegisterResult>;
// example
projectionRegister(4523).then(res => {
console.log(res); // ProjectionRegisterResult
// 注册成功
});
projectionRegisterMultiple([4523, 4527]).then(res => {
console.log(res); // ProjectionRegisterResult
// 注册成功
});
开发
- 在
src/
下开发 JS/TS 模块,例如:example.ts
- 在
test/unit
下创建单元测试文件,例如:example.spec.ts
(必须带spec.ts/js
后缀) - 引入
example.ts
中的内容编写单元测试 - 运行命令
npm test
进行测试,然后发现问题进行回归
如果需要 debug,请关闭
test/unit/karma.config.js
中的 singleRun 选项。
发布
- 在
build/config.js
中配置入口文件,例如上面的example.ts
const multiOption = [
{
// 入口
input: "src/example.ts",
// 创建输出配置
// createOutputOptions 函数传入参数为输出的文件名
output: createOutputOptions("example")
}
];
- 运行命令
npm run build
进行打包 - 运行命令
npm publish
发布包(需要登陆 npm) - 或上传
dist
目录
注意事项
- 项目根目录配置了简写路径,路径名为
package.json
的name
属性,方便外部引用。 配置其他的参考build/alias.js
与tsconfig.json
中的paths
参数。