diff --git a/bench/rollup_config_benchmarks.ts b/bench/rollup_config_benchmarks.ts index 1a08970ec3..8bfa680a4d 100644 --- a/bench/rollup_config_benchmarks.ts +++ b/bench/rollup_config_benchmarks.ts @@ -26,15 +26,11 @@ const replaceConfig = { 'process.env.NODE_ENV': JSON.stringify('production') }; -const watch = process.env.ROLLUP_WATCH === 'true'; -const srcDir = watch ? '' : 'rollup/build/tsc/'; -const inputExt = watch ? 'ts' : 'js'; - -const allPlugins = plugins(true, true, watch).concat(replace(replaceConfig)); +const allPlugins = plugins(true, true).concat(replace(replaceConfig)); const intro = fs.readFileSync('rollup/bundle_prelude.js', 'utf8'); const splitConfig = (name: string): RollupOptions[] => [{ - input: [`${srcDir}bench/${name}/benchmarks.${inputExt}`, `${srcDir}src/source/worker.${inputExt}`], + input: [`bench/${name}/benchmarks.ts`, 'src/source/worker.ts'], output: { dir: `rollup/build/benchmarks/${name}`, format: 'amd', @@ -57,7 +53,7 @@ const splitConfig = (name: string): RollupOptions[] => [{ }]; const viewConfig: RollupOptions = { - input: `${srcDir}bench/benchmarks_view.${inputExt}${watch ? 'x' : ''}`, + input: 'bench/benchmarks_view.tsx', output: { name: 'Benchmarks', file: 'bench/benchmarks_view_generated.js', @@ -67,7 +63,7 @@ const viewConfig: RollupOptions = { }, plugins: [ nodeResolve, - watch ? typescript() : null, + typescript(), commonjs(), replace(replaceConfig) ].filter(Boolean) diff --git a/build/rollup_plugins.ts b/build/rollup_plugins.ts index 83d31513f0..26614f9692 100644 --- a/build/rollup_plugins.ts +++ b/build/rollup_plugins.ts @@ -18,7 +18,7 @@ export const nodeResolve = resolve({ extensions: ['.mjs', '.js', '.json', '.node', '.ts'] }); -export const plugins = (minified: boolean, production: boolean, watch: boolean): Plugin[] => [ +export const plugins = (minified: boolean, production: boolean): Plugin[] => [ minifyStyleSpec(), json(), // https://github.com/zaach/jison/issues/351 @@ -45,7 +45,7 @@ export const plugins = (minified: boolean, production: boolean, watch: boolean): include: ['**/*'], // by default, unassert only includes .js files }) : false, nodeResolve, - watch ? typescript() : false, + typescript(), commonjs({ // global keyword handling causes Webpack compatibility issues, so we disabled it: // https://github.com/mapbox/mapbox-gl-js/pull/6956 diff --git a/package.json b/package.json index 8f17c2d5fd..c80ade8430 100644 --- a/package.json +++ b/package.json @@ -145,17 +145,13 @@ "generate-style-spec": "node --loader ts-node/esm --experimental-specifier-resolution=node build/generate-style-spec.ts", "generate-typings": "node --loader ts-node/esm --experimental-specifier-resolution=node build/generate-typings.ts", "generate-query-test-fixtures": "node --loader ts-node/esm --experimental-specifier-resolution=node build/generate-query-test-fixtures.ts", - "build-swc-src": "swc src -d rollup/build/tsc/src -D -s", - "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 --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev", + "build-dev": "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-prod": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production", + "build-prod-min": "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 --configPlugin @rollup/plugin-typescript -c rollup.config.style-spec.ts && rollup --configPlugin @rollup/plugin-typescript -c rollup.config.style-spec.ts --environment esm", + "build-style-spec": "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 --configPlugin @rollup/plugin-typescript -c bench/rollup_config_benchmarks.ts", diff --git a/rollup.config.csp.ts b/rollup.config.csp.ts index b1afef1b14..1bec4093ae 100644 --- a/rollup.config.csp.ts +++ b/rollup.config.csp.ts @@ -16,10 +16,10 @@ const config = (input: InputOption, file: string, format: ModuleFormat): RollupO banner }, treeshake: true, - plugins: plugins(true, true, false) + plugins: plugins(true, true) }); export default [ - config('rollup/build/tsc/src/index.js', 'dist/maplibre-gl-csp.js', 'umd'), - config('rollup/build/tsc/src/source/worker.js', 'dist/maplibre-gl-csp-worker.js', 'iife') + config('src/index.ts', 'dist/maplibre-gl-csp.js', 'umd'), + config('src/source/worker.ts', 'dist/maplibre-gl-csp-worker.js', 'iife') ]; diff --git a/rollup.config.style-spec.ts b/rollup.config.style-spec.ts index 5805f9c222..6f496782e3 100644 --- a/rollup.config.style-spec.ts +++ b/rollup.config.style-spec.ts @@ -6,11 +6,12 @@ import json from '@rollup/plugin-json'; import {fileURLToPath, pathToFileURL} from 'url'; import {RollupOptions} from 'rollup'; import {nodeResolve} from './build/rollup_plugins'; +import typescript from '@rollup/plugin-typescript'; const esm = 'esm' in process.env; const config: RollupOptions[] = [{ - input: 'rollup/build/tsc/src/style-spec/style-spec.js', + input: 'src/style-spec/style-spec.ts', output: { name: 'maplibreGlStyleSpecification', file: `dist/style-spec/${esm ? 'index.mjs' : 'index.js'}`, @@ -48,6 +49,7 @@ const config: RollupOptions[] = [{ json(), unassert(), nodeResolve, + typescript(), commonjs() ] }]; diff --git a/rollup.config.ts b/rollup.config.ts index 36a2d9f944..0baff87be6 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -4,11 +4,8 @@ import {plugins} from './build/rollup_plugins'; import banner from './build/banner'; import {RollupOptions} from 'rollup'; -const {BUILD, MINIFY, ROLLUP_WATCH} = process.env; +const {BUILD, MINIFY} = process.env; const minified = MINIFY === 'true'; -const watch = ROLLUP_WATCH === 'true'; -const srcDir = watch ? 'src' : 'rollup/build/tsc/src'; -const inputExt = watch ? 'ts' : 'js'; const production = BUILD === 'production'; const outputFile = !production ? 'dist/maplibre-gl-dev.js' : @@ -22,7 +19,7 @@ const config: RollupOptions[] = [{ // - rollup/build/maplibregl/shared.js: the set of modules that are dependencies of both the main module and the worker module // // This is also where we do all of our source transformations using the plugins. - input: [`${srcDir}/index.${inputExt}`, `${srcDir}/source/worker.${inputExt}`], + input: ['src/index.ts', 'src/source/worker.ts'], output: { dir: 'rollup/build/maplibregl', format: 'amd', @@ -31,7 +28,7 @@ const config: RollupOptions[] = [{ chunkFileNames: 'shared.js' }, treeshake: production, - plugins: plugins(minified, production, watch) + plugins: plugins(minified, production) }, { // Next, bundle together the three "chunks" produced in the previous pass // into a single, final bundle. See rollup/bundle_prelude.js and diff --git a/src/source/tile_id.test.ts b/src/source/tile_id.test.ts index 476169e314..1f4fdec08f 100644 --- a/src/source/tile_id.test.ts +++ b/src/source/tile_id.test.ts @@ -43,7 +43,6 @@ describe('CanonicalTileID', () => { expect(new CanonicalTileID(17, 22914, 52870).url(['quadkey={quadkey}'], 1)).toBe('quadkey=02301322130000230'); // Test case confirmed by quadkeytools package - // https://bitbucket.org/steele/quadkeytools/rollup/build/tsc/src/master/test/quadkey.js?fileviewer=file-view-default#quadkey.js-57 expect(new CanonicalTileID(6, 29, 3).url(['quadkey={quadkey}'], 1)).toBe('quadkey=011123'); }); diff --git a/test/build/style-spec.test.ts b/test/build/style-spec.test.ts index 3f587c8cde..0f5d748762 100644 --- a/test/build/style-spec.test.ts +++ b/test/build/style-spec.test.ts @@ -11,9 +11,9 @@ describe('@maplibre/maplibre-gl-style-spec npm package', () => { test('build plain ES5 bundle in prepublish', async () => { jest.spyOn(console, 'warn').mockImplementation(() => {}); await rollup.rollup({ - input: './rollup/build/tsc/src/style-spec/style-spec.js', + input: './src/style-spec/style-spec.ts', plugins: [{ - name: 'tset-checker', + name: 'test-checker', resolveId: (id, importer) => { if ( /^[\/\.]/.test(id) || @@ -31,7 +31,7 @@ describe('@maplibre/maplibre-gl-style-spec npm package', () => { }).catch(e => { expect(e).toBeFalsy(); }); - }); + }, 40000); test('exports components directly, not behind `default` - https://github.com/mapbox/mapbox-gl-js/issues/6601', () => { // @ts-ignore