Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix web worker in watch mode #968

Merged
merged 5 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions bench/rollup_config_benchmarks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import fs from 'fs';
import sourcemaps from 'rollup-plugin-sourcemaps';
import replace from '@rollup/plugin-replace';
import {plugins} from '../build/rollup_plugins';
import resolve from '@rollup/plugin-node-resolve';
import {plugins, nodeResolve} from '../build/rollup_plugins';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import {execSync} from 'child_process';
Expand Down Expand Up @@ -67,7 +66,7 @@ const viewConfig: RollupOptions = {
sourcemap: false
},
plugins: [
resolve({browser: true, preferBuiltins: false}),
nodeResolve,
watch ? typescript() : null,
commonjs(),
replace(replaceConfig)
Expand Down
11 changes: 7 additions & 4 deletions build/rollup_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import {Plugin} from 'rollup';
// Common set of plugins/transformations shared across different rollup
// builds (main maplibre bundle, style-spec package, benchmarks bundle)

export const nodeResolve = resolve({
browser: true,
preferBuiltins: false,
extensions: ['.mjs', '.js', '.json', '.node', '.ts']
});

export const plugins = (minified: boolean, production: boolean, watch: boolean): Plugin[] => [
minifyStyleSpec(),
json(),
Expand All @@ -38,10 +44,7 @@ export const plugins = (minified: boolean, production: boolean, watch: boolean):
production ? unassert({
include: ['**/*'], // by default, unassert only includes .js files
}) : false,
resolve({
browser: true,
preferBuiltins: false
}),
nodeResolve,
watch ? typescript() : false,
commonjs({
// global keyword handling causes Webpack compatibility issues, so we disabled it:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import maplibregl from '../rollup/build/tsc/src/index'
import maplibregl from '../src/index';

export default function () {
return new Worker(maplibregl.workerUrl);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"typescript": "^4.5.5"
},
"browser": {
"./rollup/build/tsc/src/util/web_worker.js": "./build/web_worker_replacement.js"
"./src/util/web_worker.ts": "./build/web_worker_replacement.ts"
},
"scripts": {
"generate-shaders": "node --loader ts-node/esm --experimental-specifier-resolution=node build/generate-shaders.ts",
Expand Down
7 changes: 2 additions & 5 deletions rollup.config.style-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path, {dirname} from 'path';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import unassert from 'rollup-plugin-unassert';
import json from '@rollup/plugin-json';
import {fileURLToPath, pathToFileURL} from 'url';
import {RollupOptions} from 'rollup';
import {nodeResolve} from './build/rollup_plugins';

const esm = 'esm' in process.env;

Expand Down Expand Up @@ -47,10 +47,7 @@ const config: RollupOptions[] = [{
}),
json(),
unassert(),
resolve({
browser: true,
preferBuiltins: false
}),
nodeResolve,
commonjs()
]
}];
Expand Down