Skip to content

Commit

Permalink
Fix rollup watch mode (#3270)
Browse files Browse the repository at this point in the history
* Fix rollup watch mode

* changelog

* fix sourcemap issue
  • Loading branch information
msbarry authored Oct 24, 2023
1 parent 6447f95 commit d8f5ae1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

- Add terrain property to map style object ([#3234](https://github.com/maplibre/maplibre-gl-js/pull/3234))
- Fix exception thrown from `isWebGL2` check ([#3238](https://github.com/maplibre/maplibre-gl-js/pull/3238))
- Fix rollup watch mode ([#3270](https://github.com/maplibre/maplibre-gl-js/pull/3270))
- _...Add new stuff here..._

## 3.5.1
Expand Down
9 changes: 9 additions & 0 deletions build/rollup_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ export const plugins = (production: boolean): Plugin[] => [
ignoreGlobal: true
})
].filter(Boolean);

export const watchStagingPlugin: Plugin = {
name: 'watch-external',
buildStart() {
this.addWatchFile('staging/maplibregl/index.js');
this.addWatchFile('staging/maplibregl/shared.js');
this.addWatchFile('staging/maplibregl/worker.js');
}
};
12 changes: 10 additions & 2 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import sourcemaps from 'rollup-plugin-sourcemaps';
import {plugins} from './build/rollup_plugins';
import {plugins, watchStagingPlugin} from './build/rollup_plugins';
import banner from './build/banner';
import {RollupOptions} from 'rollup';

Expand Down Expand Up @@ -45,11 +45,19 @@ const config: RollupOptions[] = [{
intro: fs.readFileSync('build/rollup/bundle_prelude.js', 'utf8'),
banner
},
watch: {
// give the staging chunks a chance to finish before rebuilding the dev build
buildDelay: 1000
},
treeshake: false,
plugins: [
// Ingest the sourcemaps produced in the first step of the build.
// This is the only reason we use Rollup for this second pass
sourcemaps()
sourcemaps(),
// When running in development watch mode, tell rollup explicitly to watch
// for changes to the staging chunks built by the previous step. Otherwise
// only they get built, but not the merged dev build js
...production ? [] : [watchStagingPlugin]
],
}];

Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"moduleResolution": "Node",
"resolveJsonModule": true,
"skipLibCheck": false,
"sourceMap": true,
"strict": false,
"target": "ES2016",
"lib": [
Expand Down

0 comments on commit d8f5ae1

Please sign in to comment.