File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
fixtures/function/module-side-effects-external-node-builtin-wrapped-stub Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 1- // Top-level require of a Node builtin ensures the transform computes
2- // wrappedModuleSideEffects for an external wrapped dependency .
1+ // Ensure the transform computes `wrappedModuleSideEffects` for an external
2+ // wrapped dependency by including a Node builtin `require()` inside a function .
33function unused ( ) {
4- // External Node builtin require; not executed at runtime
4+ // External Node builtin require β converted to an external proxy.
5+ // When `externalBuiltinsRequire: 'stub'`, calling this will throw; we
6+ // invoke it inside a try/catch below so the test can snapshot the emitted
7+ // stub proxy without failing at runtime.
58 require ( 'node:crypto' ) ;
69}
710
11+ try {
12+ unused ( ) ;
13+ } catch { }
14+
815module . exports = 1 ;
Original file line number Diff line number Diff line change @@ -6742,12 +6742,27 @@ Generated by [AVA](https://avajs.dev).
67426742 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;β
67436743 }β
67446744 β
6745+ function __require() { throw new Error("Node built-in node:crypto is not available in this environment"); }β
6746+ β
67456747 var main$1;β
67466748 var hasRequiredMain;β
67476749 β
67486750 function requireMain () {β
67496751 if (hasRequiredMain) return main$1;β
67506752 hasRequiredMain = 1;β
6753+ // Ensure the transform computes \`wrappedModuleSideEffects\` for an externalβ
6754+ // wrapped dependency by including a Node builtin \`require()\` inside a function.β
6755+ function unused() {β
6756+ // External Node builtin require β converted to an external proxy.β
6757+ // When \`externalBuiltinsRequire: 'stub'\`, calling this will throw; weβ
6758+ // invoke it inside a try/catch below so the test can snapshot the emittedβ
6759+ // stub proxy without failing at runtime.β
6760+ __require();β
6761+ }β
6762+ β
6763+ try {β
6764+ unused();β
6765+ } catch {}β
67516766 β
67526767 main$1 = 1;β
67536768 return main$1;β
You canβt perform that action at this time.
0 commit comments