Skip to content

Commit cf98805

Browse files
committed
refactor build tooling
1 parent 5367938 commit cf98805

70 files changed

Lines changed: 6357 additions & 8533 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.browserslistrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IE 11

.parcelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ The asynchronous APIs also use `Worker`, which is not supported in a few browser
543543
Other than that, `fflate` is completely ES3, meaning you probably won't even need a bundler to use it.
544544

545545
## Testing
546-
You can validate the performance of `fflate` with `npm`/`yarn`/`pnpm` `test`. It validates that the module is working as expected, ensures the outputs are no more than 5% larger than competitors at max compression, and outputs performance metrics to `test/results`.
546+
You can validate the performance of `fflate` with `npm test`. It validates that the module is working as expected, ensures the outputs are no more than 5% larger than competitors at max compression, and outputs performance metrics to `test/results`.
547547

548548
Note that the time it takes for the CLI to show the completion of each test is not representative of the time each package took, so please check the JSON output if you want accurate measurements.
549549

demo/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const App: FC = () => {
7171
marginBottom: '2vh'
7272
}}>
7373
<FilePicker allowDirs onFiles={setFiles} onError={setErr} onDrag={() => {}}>
74-
{err && <div style={{ color: 'red' }}>Error: {err}</div>}
74+
{err && <div style={{ color: 'red' }}>Error: {err.toString()}</div>}
7575
<div>{files ? ((files.length || 'No') + ' file' + (files.length == 1 ? '' : 's') + ' selected') : 'Loading...'}</div>
7676
<br />
7777
</FilePicker>

demo/augment.d.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,3 @@ declare module 'uzip' {
99
}
1010
export = UZIP;
1111
}
12-
13-
interface DataTransferItem {
14-
webkitGetAsEntry(): FileSystemEntry;
15-
}
16-
17-
interface BaseFileSystemEntry {
18-
fullPath: string;
19-
name: string;
20-
isFile: boolean;
21-
isDirectory: boolean;
22-
}
23-
24-
interface FileSystemFileEntry extends BaseFileSystemEntry {
25-
isFile: true;
26-
isDirectory: false
27-
file(onSuccess: (file: File) => void, onError: (err: Error) => void): void;
28-
}
29-
30-
type FileSystemEntry = FileSystemFileEntry | FileSystemDirectoryEntry;
31-
32-
33-
interface FileSystemDirectoryReader {
34-
readEntries(onSuccess: (entries: FileSystemEntry[]) => void, onError: (err: Error) => void): void;
35-
}
36-
37-
interface FileSystemDirectoryEntry extends BaseFileSystemEntry {
38-
isFile: false;
39-
isDirectory: true;
40-
createReader(): FileSystemDirectoryReader;
41-
}
42-
43-
interface File {
44-
webkitRelativePath: string;
45-
}

demo/components/code-box/sandbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const createWorkerProxy = (lib: string, keys: string[]): WorkerProxy => {
1818
const p: WorkerProxy = {};
1919
for (const k of keys) {
2020
const base = function(cb: (...args: unknown[]) => void) {
21-
const w = new Worker('../../util/workers.ts');
21+
const w = new Worker(new URL('../../util/workers.ts', import.meta.url), { type: 'module' });
2222
w.postMessage([lib, k]);
2323
w.onmessage = function(msg) {
2424
const args = msg.data;

demo/components/file-picker/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const readRecurse = (dir: FileSystemDirectoryEntry, onComplete: (files: File[])
2727
} else reader.readEntries(onRead, onError);
2828
for (const entry of entries) {
2929
++total;
30-
if (entry.isFile) entry.file(f => onDone([
30+
if (entry.isFile) (entry as FileSystemFileEntry).file(f => onDone([
3131
new File([f], entry.fullPath.slice(1), f)
3232
]), onErr);
3333
else readRecurse(entry as FileSystemDirectoryEntry, onDone, onErr);
@@ -77,8 +77,8 @@ const FilePicker: FC<{
7777
if (!--lft && !errored) onFiles(outFiles);
7878
};
7979
for (let i = 0; i < tf.items.length; ++i) {
80-
const entry = tf.items[i].webkitGetAsEntry();
81-
if (entry.isFile) entry.file(f => onDone([f]), onErr);
80+
const entry = tf.items[i].webkitGetAsEntry()!;
81+
if (entry.isFile) (entry as FileSystemFileEntry).file(f => onDone([f]), onErr);
8282
else readRecurse(entry as FileSystemDirectoryEntry, onDone, onErr);
8383
}
8484
} else onFiles(Array.prototype.slice.call(tf.files));

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
</head>
1111
<body>
1212
<div id="app"></div>
13-
<script src="index.tsx"></script>
13+
<script type="module" src="index.tsx"></script>
1414
</body>
1515
</html>

demo/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import App from './App';
3-
import { render } from 'react-dom';
3+
import { createRoot } from 'react-dom/client';
44

55
if (process.env.NODE_ENV == 'production') {
66
if ('serviceWorker' in navigator) {
7-
navigator.serviceWorker.register('sw.ts');
7+
navigator.serviceWorker.register(new URL('sw.ts', import.meta.url), { type: 'module' });
88
}
99
}
1010

11-
render(<App />, document.getElementById('app'));
11+
createRoot(document.getElementById('app')!).render(<App />);

demo/sw.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
/// <reference lib="webworker" />
2+
import { manifest, version } from '@parcel/service-worker'
23

3-
const sw = self as unknown as ServiceWorkerGlobalScope & {
4-
__precacheManifest: ({ url: string, revision: string })[];
5-
};
6-
7-
const precacheVersion = sw.__precacheManifest
8-
.map(p => p.revision)
9-
.join('');
10-
const precacheFiles = sw.__precacheManifest.map(p => p.url).filter(
11-
u => /\.(ico)$/.test(u)
12-
);
4+
const precacheVersion = version
5+
const precacheFiles = manifest.filter(u => /\.(ico)$/.test(u));
136

147
const ch = () => caches.open(precacheVersion);
158

0 commit comments

Comments
 (0)