-
Notifications
You must be signed in to change notification settings - Fork 20
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
esbuild #229
base: main
Are you sure you want to change the base?
esbuild #229
Changes from all commits
2e6a1a2
9449079
b74ac2c
4f6ff72
8bdfc56
fd970e8
9fd9e45
bbfb435
92192f8
ad5aaa5
5c223c8
2ee86c3
3ab77e2
2951998
2f0fd13
35d6ae4
2330459
e526dde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const { | ||
NodeGlobalsPolyfillPlugin, | ||
} = require('@esbuild-plugins/node-globals-polyfill'); | ||
|
||
const { build } = require('esbuild'); | ||
|
||
/** | ||
* @type {import('esbuild').BuildOptions} | ||
*/ | ||
const sharedOptions = { | ||
entryPoints: ['./src/index.ts', './src/worker.penumbra.js'], | ||
sourcemap: true, | ||
bundle: true, | ||
}; | ||
|
||
/** | ||
* @type {import('esbuild').BuildOptions} | ||
*/ | ||
const browserOptions = { | ||
platform: 'browser', | ||
plugins: [ | ||
NodeGlobalsPolyfillPlugin({ | ||
process: true, | ||
buffer: true, | ||
}), | ||
], | ||
define: { | ||
global: 'globalThis', | ||
}, | ||
}; | ||
|
||
/** | ||
* @type {import('esbuild').BuildOptions} | ||
*/ | ||
const cjsOptions = { | ||
...sharedOptions, | ||
...browserOptions, | ||
format: 'iife', | ||
minify: true, | ||
outdir: './dist/cjs/', | ||
globalName: 'penumbra', | ||
}; | ||
build(cjsOptions).catch(() => process.exit(1)); | ||
|
||
/** | ||
* @type {import('esbuild').BuildOptions} | ||
*/ | ||
const esmOptions = { | ||
...sharedOptions, | ||
...browserOptions, | ||
format: 'esm', | ||
outdir: './dist/esm/', | ||
}; | ||
build(esmOptions).catch(() => process.exit(1)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Penumbra Tests</title> | ||
<meta charset="UTF-8" /> | ||
<!--<link rel="stylesheet" type="text/css" href="style.css" />--> | ||
</head> | ||
|
||
<body> | ||
<div id="app"> | ||
<h1>Penumbra Tests</h1> | ||
</div> | ||
<div> | ||
<p>Open your console (Option+Command+I) to view test results.</p> | ||
</div> | ||
<script type="module"> | ||
const cacheBuster = Math.random().toString(10).slice(2); | ||
const { penumbra } = await import(`/dist/esm/index.js?${cacheBuster}`); | ||
// ESM workers blocked by Firefox support | ||
penumbra.setWorkerLocation(`/dist/cjs/worker.penumbra.js?${cacheBuster}`); | ||
const demo = document.createElement('script'); | ||
demo.src = `demo.js?${cacheBuster}`; | ||
document.body.appendChild(demo); | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
/** Webpack worker-loader type setup */ | ||
declare module 'worker-loader!*' { | ||
declare module 'web-worker:*' { | ||
/** Worker */ | ||
class WebpackWorker extends Worker { | ||
/** Webpack's Worker constructor */ | ||
public constructor(); | ||
} | ||
|
||
export default WebpackWorker; | ||
class PenumbraWebWorker extends Worker {} | ||
export default PenumbraWebWorker; | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { | |
RemoteReadableStream, | ||
RemoteWritableStream, | ||
} from '@transcend-io/remote-web-streams'; | ||
import mime from 'mime-types'; | ||
import { getExtension } from 'mime'; | ||
import { streamSaver } from './streamsaver'; | ||
import { ReadableStream } from './streams'; | ||
|
||
|
@@ -178,7 +178,7 @@ function save( | |
'stream' in files ? (files as unknown as PenumbraFile) : files[0]; | ||
const [ | ||
filename, | ||
extension = file.mimetype ? mime.extension(file.mimetype) : '', | ||
extension = file.mimetype ? `.${getExtension(file.mimetype)}` : '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lighter mime type lib meant for browsers. also noticed neither library returns with a |
||
] = (fileName || file.filePrefix || DEFAULT_FILENAME) | ||
.split(/(\.\w+\s*$)/) // split filename extension | ||
.filter(Boolean); // filter empty matches | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
export const settings = ( | ||
document.currentScript || | ||
document.querySelector('script[data-penumbra]') || | ||
({ dataset: {} } as HTMLScriptElement) | ||
).dataset; | ||
export const settings = | ||
(document.currentScript || document.querySelector('script[data-penumbra]')) | ||
?.dataset || ({} as DOMStringMap); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,5 @@ export { default as getTextFromRS } from './getTextFromRS'; | |
export { default as toBuff } from './toBuff'; | ||
export { default as blobCache } from './blobCache'; | ||
export { default as isViewableText } from './isViewableText'; | ||
export { default as intoStream } from './intoStream'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused + is the only thing depending on |
||
export { default as isNumber } from './isNumber'; | ||
export { default as throwOutside } from './throwOutside'; |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not in use - can delete