Skip to content

Commit

Permalink
bundle d.ts files (#2311)
Browse files Browse the repository at this point in the history
* add merge d.ts files script

* userollup-plugin-dts plugin for bundle d.ts files
  • Loading branch information
deyihu authored Apr 23, 2024
1 parent 36744c9 commit 9a6ace4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
"module": "dist/index.js",
"module_browser": "dist/maptalks.es.js",
"main": "dist/maptalks.js",
"minify":"dist/maptalks.min.js",
"minify": "dist/maptalks.min.js",
"jsnext:main": "dist/index.js",
"style": "dist/maptalks.css",
"d.ts": "dist/maptalks.d.ts",
"dependencies": {
"@maptalks/feature-filter": "^1.3.0",
"@maptalks/function-type": "^1.3.1",
Expand All @@ -62,6 +63,7 @@
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.11.30",
"@types/offscreencanvas": "^2019.7.3",
"rollup-plugin-dts": "^6.1.0",
"eslint": "^8.57.0",
"eslint-plugin-mocha": "^10.4.1",
"expect-maptalks": "^0.4.1",
Expand Down Expand Up @@ -89,4 +91,4 @@
"@rollup/rollup-darwin-x64": "^4.13.0",
"@rollup/rollup-linux-x64-gnu": "^4.13.0"
}
}
}
16 changes: 15 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const commonjs = require('@rollup/plugin-commonjs'),
typescript = require('@rollup/plugin-typescript'),
terser = require('@rollup/plugin-terser');
const pkg = require('./package.json');
const { dts } = require("rollup-plugin-dts");

const testing = process.env.BUILD === 'test';
const dev = process.env.BUILD === 'dev';
Expand Down Expand Up @@ -64,6 +65,19 @@ const builds = [
}
]
},
{
input: 'dist/index.d.ts',
plugins: [dts()],
output: [
{
'sourcemap': true,
'format': 'es',
'name': 'maptalks',
banner,
'file': pkg['d.ts']
}
]
},
{
input: 'src/index.ts',
plugins: rollupPlugins.concat([terser()]),
Expand Down Expand Up @@ -94,7 +108,7 @@ const builds = [
];

if (isDebug) {
module.exports = [builds[0]];
module.exports = builds.slice(0, 2);
} else {
module.exports = builds;
}
4 changes: 2 additions & 2 deletions src/geo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export { default as PointExtent } from './PointExtent';
export { default as Size } from './Size';
export { default as Transformation } from './transformation/Transformation';

import * as projection from './projection';
import * as measurer from './measurer';
import * as projection from './projection/index';
import * as measurer from './measurer/index';

export { projection, measurer };
20 changes: 10 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export { default as GlobalConfig } from './GlobalConfig';
export * from './core/ResourceProxy';
export * from './core/Constants';
export { default as Browser } from './core/Browser';
import * as Util from './core/util';
import * as Util from './core/util/index';
import * as DomUtil from './core/util/dom';
import * as StringUtil from './core/util/strings';
import * as MapboxUtil from './core/mapbox';
Expand All @@ -27,26 +27,26 @@ export { default as Handler } from './handler/Handler';
export { default as DragHandler } from './handler/Drag';

// geo classes
export * from './geo';
export * from './geo/index';

import { Map } from './map';
import { Map } from './map/index';
Map.VERSION = version;
export { Map };

export { MapTool, DrawTool, AreaTool, DistanceTool } from './map/tool';
export { MapTool, DrawTool, AreaTool, DistanceTool } from './map/tool/index';
export { default as SpatialReference } from './map/spatial-reference/SpatialReference';
// import './map/spatial-reference/SpatialReference.Arc';
// import './map/spatial-reference/SpatialReference.WMTS';

/** @namespace ui */
import * as ui from './ui';
import * as ui from './ui/index';
/** @namespace control */
import * as control from './control';
import * as control from './control/index';
export { ui, control };

export * from './layer';
export * from './layer/index';

export * from './geometry';
export * from './geometry/index';

import './geometry/editor/GeometryEditor';
import './geometry/editor/TextEditable';
Expand All @@ -62,11 +62,11 @@ import './geometry/ext/Geometry.JSON';
* @namespace renderer
*/
// import layer renderers
import * as renderer from './renderer';
import * as renderer from './renderer/index';
export { renderer };
// import geometry renderers
import './renderer/geometry';
import * as symbolizer from './renderer/geometry/symbolizers';
import * as symbolizer from './renderer/geometry/symbolizers/index';
/** @namespace animation */
import * as animation from './core/Animation';
export { symbolizer, animation };
Expand Down

0 comments on commit 9a6ace4

Please sign in to comment.