1tube 0.1.36 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -544,6 +544,25 @@ function entryProxyPlugin(
|
|
|
544
544
|
|
|
545
545
|
const NODE_BUILTIN_SET = new Set<string>(NODE_BUILTIN_MODULES);
|
|
546
546
|
|
|
547
|
+
/**
|
|
548
|
+
* Optional native/peer packages that popular Node libraries `require()` from
|
|
549
|
+
* inside a `try/catch` as an opt-in speedup, degrading to a pure-JS path when
|
|
550
|
+
* absent. They are `optionalDependencies` that are not installed, so esbuild's
|
|
551
|
+
* deno loader fails to resolve them when the Vercel (Node) target selects the
|
|
552
|
+
* libraries' `node` build. Marking them external makes esbuild emit its
|
|
553
|
+
* `__require` shim (which throws at the call site); the library catches that
|
|
554
|
+
* and uses its fallback. The workerd target never hits this because its
|
|
555
|
+
* `browser`/`worker` conditions resolve the dependency-free browser builds.
|
|
556
|
+
*
|
|
557
|
+
* - `bufferutil`, `utf-8-validate` → `ws` (native frame masking / UTF-8 check)
|
|
558
|
+
* - `supports-color` → `debug` (TTY colour detection)
|
|
559
|
+
*/
|
|
560
|
+
const VERCEL_OPTIONAL_EXTERNALS: readonly string[] = [
|
|
561
|
+
"bufferutil",
|
|
562
|
+
"utf-8-validate",
|
|
563
|
+
"supports-color",
|
|
564
|
+
];
|
|
565
|
+
|
|
547
566
|
function isNodeBuiltinBare(spec: string): boolean {
|
|
548
567
|
const slash = spec.indexOf("/");
|
|
549
568
|
const head = slash === -1 ? spec : spec.slice(0, slash);
|
|
@@ -789,6 +808,11 @@ export async function bundleAllChunked(
|
|
|
789
808
|
conditions: isVercel
|
|
790
809
|
? ["node", "import", "default"]
|
|
791
810
|
: ["worker", "browser", "import", "default"],
|
|
811
|
+
// Optional native deps that `ws`/`debug` require() behind a try/catch.
|
|
812
|
+
// The deno loader honors esbuild's `external`, short-circuiting them to
|
|
813
|
+
// external so the Node build resolves without their (uninstalled)
|
|
814
|
+
// optionalDependencies. Workerd resolves the browser build and needs none.
|
|
815
|
+
external: isVercel ? [...VERCEL_OPTIONAL_EXTERNALS] : undefined,
|
|
792
816
|
sourcemap,
|
|
793
817
|
minify: opts.minify ?? false,
|
|
794
818
|
treeShaking: true,
|