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

Speed up builds by not bundling typescript #398

Merged
merged 1 commit into from
Mar 20, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- Upgraded to TypeScript 5.2 and Lit 3.0
- **BREAKING** Use modules in workers. See [caniuse.com's support table](https://caniuse.com/mdn-api_worker_worker_ecmascript_modules) for browser support information.

<!-- ### Added -->
<!-- ### Fixed -->
Expand Down
5 changes: 2 additions & 3 deletions rollup.config.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ import commonjs from '@rollup/plugin-commonjs';
* because we don't need to run the commonjs transform every time we build the
* worker.
*
* - We may want to use module imports in the worker at some point, for a faster
* development mode that doesn't bundle. Having only module sources will make
* this easier too.
* - We use module imports in the worker, for a faster development mode that
* doesn't bundle. Having only module sources makes this easier too.
*/
export default [
{
Expand Down
11 changes: 10 additions & 1 deletion rollup.config.web-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@

import resolve from '@rollup/plugin-node-resolve';
import {maybeTerser} from './rollup.config.common.js';
import * as path from 'path';

const internalTypescriptPath = path.resolve(process.cwd(), 'internal/typescript.js');

export default {
input: 'typescript-worker/playground-typescript-worker.js',
external(id, parentId, isResolved) {
if (!isResolved && parentId !== undefined) {
id = path.resolve(path.dirname(parentId), id);
}
return id === internalTypescriptPath;
},
output: {
file: 'playground-typescript-worker.js',
format: 'iife',
format: 'esm',
exports: 'none',
},
plugins: [resolve(), ...maybeTerser],
Expand Down
2 changes: 1 addition & 1 deletion src/playground-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export class PlaygroundProject extends LitElement {
let worker: Worker;
if (typescriptWorkerScriptUrl.origin === window.location.origin) {
// Easy case.
worker = new Worker(typescriptWorkerScriptUrl);
worker = new Worker(typescriptWorkerScriptUrl, {type: 'module'});
} else {
// If the worker script is different-origin, we need to fetch it ourselves
// and create a blob URL.
Expand Down
Loading