Skip to content

Commit

Permalink
Rollup config to ts (#962)
Browse files Browse the repository at this point in the history
* Move rollup config to ts

* Update file paths in package.json
  • Loading branch information
birkskyum authored Feb 7, 2022
1 parent cfcf380 commit 15f24aa
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ const viewConfig = {
].filter(Boolean)
};

// @ts-ignore
export default splitConfig('versions').concat(splitConfig('styles')).concat(viewConfig);
2 changes: 1 addition & 1 deletion build/banner.js → build/banner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';

const version = JSON.parse(fs.readFileSync('package.json')).version;
const version = JSON.parse(fs.readFileSync('package.json').toString()).version;
export default `/* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v${version}/LICENSE.txt */`;
File renamed without changes.
5 changes: 3 additions & 2 deletions build/rollup_plugins.js → build/rollup_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import commonjs from '@rollup/plugin-commonjs';
import unassert from 'rollup-plugin-unassert';
import json from '@rollup/plugin-json';
import {terser} from 'rollup-plugin-terser';
import minifyStyleSpec from './rollup_plugin_minify_style_spec.js';
import minifyStyleSpec from './rollup_plugin_minify_style_spec';
import strip from '@rollup/plugin-strip';

// Common set of plugins/transformations shared across different rollup
Expand All @@ -30,6 +30,7 @@ export const plugins = (minified, production, watch) => [
}) : false,
minified ? terser({
compress: {
// eslint-disable-next-line camelcase
pure_getters: true,
passes: 3
}
Expand All @@ -47,4 +48,4 @@ export const plugins = (minified, production, watch) => [
// https://github.com/mapbox/mapbox-gl-js/pull/6956
ignoreGlobal: true
})
].filter(Boolean);
].filter(Boolean);
19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,17 @@
"build-swc-bench": "swc bench -d rollup/build/tsc/bench -D -s",
"build-tsc": "npm run build-swc-src && npm run build-swc-bench",
"build-tsc-old": "tsc --outDir rollup/build/tsc",
"build-dev": "npm run build-tsc && rollup -c --environment BUILD:dev",
"watch-dev": "rollup -c --environment BUILD:dev --watch",
"build-prod": "npm run build-tsc && rollup -c --environment BUILD:production",
"build-prod-min": "npm run build-tsc && rollup -c --environment BUILD:production,MINIFY:true",
"build-csp": "rollup -c rollup.config.csp.js",
"build-query-suite": "rollup -c test/integration/rollup.config.test.js",
"build-dev": "npm run build-tsc && rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev",
"watch-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch",
"build-prod": "npm run build-tsc && rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production",
"build-prod-min": "npm run build-tsc && rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production,MINIFY:true",
"build-csp": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts",
"build-css": "postcss -o dist/maplibre-gl.css src/css/maplibre-gl.css",
"build-style-spec": "npm run build-tsc && rollup -c rollup.config.style-spec.js && rollup -c rollup.config.style-spec.js --environment esm",
"build-style-spec": "npm run build-tsc && rollup --configPlugin @rollup/plugin-typescript -c rollup.config.style-spec.ts && rollup --configPlugin @rollup/plugin-typescript -c rollup.config.style-spec.ts --environment esm",
"build-diagrams": "cd docs/diagrams; ls *.plantuml | xargs -I {} puml generate --svg {} -o {}.svg",
"watch-css": "postcss --watch -o dist/maplibre-gl.css src/css/maplibre-gl.css",
"build-benchmarks": "npm run build-dev && rollup -c bench/rollup_config_benchmarks.js",
"watch-benchmarks": "rollup -c bench/rollup_config_benchmarks.js --watch",
"build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c bench/rollup_config_benchmarks.ts",
"watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c bench/rollup_config_benchmarks.ts --watch",
"start-server": "st --no-cache -H 0.0.0.0 --port 9966 --index index.html .",
"start": "run-p watch-css start-server",
"start-debug": "run-p watch-css watch-dev start-server",
Expand All @@ -169,8 +168,6 @@
"lint-docs": "documentation lint src/index.ts",
"lint-css": "stylelint \"src/css/maplibre-gl.css\"",
"test": "run-s lint lint-css lint-docs test-unit",
"test-suite": "run-s test-render test-expression",
"test-suite-clean": "find test/integration/{render, expression}-tests -mindepth 2 -type d -exec test -e \"{}/actual.png\" \\; -not \\( -exec test -e \"{}/style.json\" \\; \\) -print | xargs -t rm -r",
"test-build": "jest ./test/build",
"test-symbol-shaping": "jest ./test/integration/symbol-shaping",
"test-style-spec": "jest ./test/integration/style-spec",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.csp.js → rollup.config.csp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const config = (input, file, format) => ({
banner
},
treeshake: true,
plugins: plugins(true, true)
plugins: plugins(true, true, false)
});

export default [
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions rollup.config.js → rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import sourcemaps from 'rollup-plugin-sourcemaps';
import {plugins} from './build/rollup_plugins.js';
import banner from './build/banner.js';
import {plugins} from './build/rollup_plugins';
import banner from './build/banner';

const {BUILD, MINIFY, ROLLUP_WATCH} = process.env;
const minified = MINIFY === 'true';
Expand All @@ -11,7 +11,7 @@ const inputExt = watch ? 'ts' : 'js';
const production = BUILD === 'production';
const outputFile =
!production ? 'dist/maplibre-gl-dev.js' :
minified ? 'dist/maplibre-gl.js' : 'dist/maplibre-gl-unminified.js';
minified ? 'dist/maplibre-gl.js' : 'dist/maplibre-gl-unminified.js';

export default [{
// Before rollup you should run build-tsc to transpile from typescript to javascript (except when running rollup in watch mode)
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
"types": ["node", "jest", "geojson", "offscreencanvas"]
},
"include": [
"rollup.config.**",
"src/**/*.ts",
"bench/**/*.ts",
"bench/**/*.tsx"
"bench/**/*.tsx",
"build/**/*.ts"
],
"exclude": [
"node_modules",
Expand Down

0 comments on commit 15f24aa

Please sign in to comment.