Skip to content

Commit

Permalink
Speed up builds by not bundling typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfagnani committed Mar 20, 2024
1 parent aba2f14 commit ef952fa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
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

0 comments on commit ef952fa

Please sign in to comment.