@vercel/node 2.11.0 → 2.13.0
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/dist/{dev-server.js → dev-server.mjs} +34 -42
- package/dist/edge-functions/edge-handler-template.js +22 -45
- package/dist/edge-functions/{edge-handler.js → edge-handler.mjs} +56 -56
- package/dist/edge-functions/{edge-node-compat-plugin.js → edge-node-compat-plugin.mjs} +12 -20
- package/dist/edge-functions/{edge-wasm-plugin.js → edge-wasm-plugin.mjs} +7 -12
- package/dist/fork-dev-server.js +7 -13
- package/dist/index.d.ts +20 -12
- package/dist/index.js +143 -207
- package/dist/serverless-functions/helpers.js +221 -0
- package/dist/serverless-functions/serverless-handler.mjs +65 -0
- package/dist/typescript.js +4 -4
- package/dist/utils.js +13 -7
- package/package.json +13 -11
- package/dist/edge-functions/edge-handler.d.ts +0 -4
- package/dist/edge-functions/edge-node-compat-plugin.d.ts +0 -15
- package/dist/edge-functions/edge-wasm-plugin.d.ts +0 -21
- package/dist/fork-dev-server.d.ts +0 -34
- package/dist/serverless-functions/serverless-handler.d.ts +0 -7
- package/dist/serverless-functions/serverless-handler.js +0 -47
package/dist/index.js
CHANGED
@@ -15545,7 +15545,7 @@ function hoistVariables(path, emit, kind = "var") {
|
|
15545
15545
|
|
15546
15546
|
/***/ }),
|
15547
15547
|
|
15548
|
-
/***/
|
15548
|
+
/***/ 92288:
|
15549
15549
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
15550
15550
|
|
15551
15551
|
"use strict";
|
@@ -15555,11 +15555,8 @@ Object.defineProperty(exports, "__esModule", ({
|
|
15555
15555
|
value: true
|
15556
15556
|
}));
|
15557
15557
|
exports.default = void 0;
|
15558
|
-
|
15559
15558
|
var _assert = __webpack_require__(42357);
|
15560
|
-
|
15561
15559
|
var _t = __webpack_require__(32338);
|
15562
|
-
|
15563
15560
|
const {
|
15564
15561
|
callExpression,
|
15565
15562
|
cloneNode,
|
@@ -15574,7 +15571,6 @@ const {
|
|
15574
15571
|
variableDeclaration,
|
15575
15572
|
variableDeclarator
|
15576
15573
|
} = _t;
|
15577
|
-
|
15578
15574
|
class ImportBuilder {
|
15579
15575
|
constructor(importedSource, scope, hub) {
|
15580
15576
|
this._statements = [];
|
@@ -15584,139 +15580,102 @@ class ImportBuilder {
|
|
15584
15580
|
this._hub = hub;
|
15585
15581
|
this._importedSource = importedSource;
|
15586
15582
|
}
|
15587
|
-
|
15588
15583
|
done() {
|
15589
15584
|
return {
|
15590
15585
|
statements: this._statements,
|
15591
15586
|
resultName: this._resultName
|
15592
15587
|
};
|
15593
15588
|
}
|
15594
|
-
|
15595
15589
|
import() {
|
15596
15590
|
this._statements.push(importDeclaration([], stringLiteral(this._importedSource)));
|
15597
|
-
|
15598
15591
|
return this;
|
15599
15592
|
}
|
15600
|
-
|
15601
15593
|
require() {
|
15602
15594
|
this._statements.push(expressionStatement(callExpression(identifier("require"), [stringLiteral(this._importedSource)])));
|
15603
|
-
|
15604
15595
|
return this;
|
15605
15596
|
}
|
15606
|
-
|
15607
15597
|
namespace(name = "namespace") {
|
15608
15598
|
const local = this._scope.generateUidIdentifier(name);
|
15609
|
-
|
15610
15599
|
const statement = this._statements[this._statements.length - 1];
|
15611
|
-
|
15612
15600
|
_assert(statement.type === "ImportDeclaration");
|
15613
|
-
|
15614
15601
|
_assert(statement.specifiers.length === 0);
|
15615
|
-
|
15616
15602
|
statement.specifiers = [importNamespaceSpecifier(local)];
|
15617
15603
|
this._resultName = cloneNode(local);
|
15618
15604
|
return this;
|
15619
15605
|
}
|
15620
|
-
|
15621
15606
|
default(name) {
|
15622
15607
|
const id = this._scope.generateUidIdentifier(name);
|
15623
|
-
|
15624
15608
|
const statement = this._statements[this._statements.length - 1];
|
15625
|
-
|
15626
15609
|
_assert(statement.type === "ImportDeclaration");
|
15627
|
-
|
15628
15610
|
_assert(statement.specifiers.length === 0);
|
15629
|
-
|
15630
15611
|
statement.specifiers = [importDefaultSpecifier(id)];
|
15631
15612
|
this._resultName = cloneNode(id);
|
15632
15613
|
return this;
|
15633
15614
|
}
|
15634
|
-
|
15635
15615
|
named(name, importName) {
|
15636
15616
|
if (importName === "default") return this.default(name);
|
15637
|
-
|
15638
15617
|
const id = this._scope.generateUidIdentifier(name);
|
15639
|
-
|
15640
15618
|
const statement = this._statements[this._statements.length - 1];
|
15641
|
-
|
15642
15619
|
_assert(statement.type === "ImportDeclaration");
|
15643
|
-
|
15644
15620
|
_assert(statement.specifiers.length === 0);
|
15645
|
-
|
15646
15621
|
statement.specifiers = [importSpecifier(id, identifier(importName))];
|
15647
15622
|
this._resultName = cloneNode(id);
|
15648
15623
|
return this;
|
15649
15624
|
}
|
15650
|
-
|
15651
15625
|
var(name) {
|
15652
15626
|
const id = this._scope.generateUidIdentifier(name);
|
15653
|
-
|
15654
15627
|
let statement = this._statements[this._statements.length - 1];
|
15655
|
-
|
15656
15628
|
if (statement.type !== "ExpressionStatement") {
|
15657
15629
|
_assert(this._resultName);
|
15658
|
-
|
15659
15630
|
statement = expressionStatement(this._resultName);
|
15660
|
-
|
15661
15631
|
this._statements.push(statement);
|
15662
15632
|
}
|
15663
|
-
|
15664
15633
|
this._statements[this._statements.length - 1] = variableDeclaration("var", [variableDeclarator(id, statement.expression)]);
|
15665
15634
|
this._resultName = cloneNode(id);
|
15666
15635
|
return this;
|
15667
15636
|
}
|
15668
|
-
|
15669
15637
|
defaultInterop() {
|
15670
15638
|
return this._interop(this._hub.addHelper("interopRequireDefault"));
|
15671
15639
|
}
|
15672
|
-
|
15673
15640
|
wildcardInterop() {
|
15674
15641
|
return this._interop(this._hub.addHelper("interopRequireWildcard"));
|
15675
15642
|
}
|
15676
|
-
|
15677
15643
|
_interop(callee) {
|
15678
15644
|
const statement = this._statements[this._statements.length - 1];
|
15679
|
-
|
15680
15645
|
if (statement.type === "ExpressionStatement") {
|
15681
15646
|
statement.expression = callExpression(callee, [statement.expression]);
|
15682
15647
|
} else if (statement.type === "VariableDeclaration") {
|
15683
15648
|
_assert(statement.declarations.length === 1);
|
15684
|
-
|
15685
15649
|
statement.declarations[0].init = callExpression(callee, [statement.declarations[0].init]);
|
15686
15650
|
} else {
|
15687
15651
|
_assert.fail("Unexpected type.");
|
15688
15652
|
}
|
15689
|
-
|
15690
15653
|
return this;
|
15691
15654
|
}
|
15692
|
-
|
15693
15655
|
prop(name) {
|
15694
15656
|
const statement = this._statements[this._statements.length - 1];
|
15695
|
-
|
15696
15657
|
if (statement.type === "ExpressionStatement") {
|
15697
15658
|
statement.expression = memberExpression(statement.expression, identifier(name));
|
15698
15659
|
} else if (statement.type === "VariableDeclaration") {
|
15699
15660
|
_assert(statement.declarations.length === 1);
|
15700
|
-
|
15701
15661
|
statement.declarations[0].init = memberExpression(statement.declarations[0].init, identifier(name));
|
15702
15662
|
} else {
|
15703
15663
|
_assert.fail("Unexpected type:" + statement.type);
|
15704
15664
|
}
|
15705
|
-
|
15706
15665
|
return this;
|
15707
15666
|
}
|
15708
|
-
|
15709
15667
|
read(name) {
|
15710
15668
|
this._resultName = memberExpression(this._resultName, identifier(name));
|
15711
15669
|
}
|
15712
|
-
|
15713
15670
|
}
|
15714
|
-
|
15715
15671
|
exports.default = ImportBuilder;
|
15716
15672
|
|
15673
|
+
//# sourceMappingURL=import-builder.js.map
|
15674
|
+
|
15675
|
+
|
15717
15676
|
/***/ }),
|
15718
15677
|
|
15719
|
-
/***/
|
15678
|
+
/***/ 37615:
|
15720
15679
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
15721
15680
|
|
15722
15681
|
"use strict";
|
@@ -15726,20 +15685,14 @@ Object.defineProperty(exports, "__esModule", ({
|
|
15726
15685
|
value: true
|
15727
15686
|
}));
|
15728
15687
|
exports.default = void 0;
|
15729
|
-
|
15730
15688
|
var _assert = __webpack_require__(42357);
|
15731
|
-
|
15732
15689
|
var _t = __webpack_require__(32338);
|
15733
|
-
|
15734
|
-
var
|
15735
|
-
|
15736
|
-
var _isModule = __webpack_require__(77901);
|
15737
|
-
|
15690
|
+
var _importBuilder = __webpack_require__(92288);
|
15691
|
+
var _isModule = __webpack_require__(59462);
|
15738
15692
|
const {
|
15739
15693
|
numericLiteral,
|
15740
15694
|
sequenceExpression
|
15741
15695
|
} = _t;
|
15742
|
-
|
15743
15696
|
class ImportInjector {
|
15744
15697
|
constructor(path, importedSource, opts) {
|
15745
15698
|
this._defaultOpts = {
|
@@ -15757,46 +15710,35 @@ class ImportInjector {
|
|
15757
15710
|
this._hub = programPath.hub;
|
15758
15711
|
this._defaultOpts = this._applyDefaults(importedSource, opts, true);
|
15759
15712
|
}
|
15760
|
-
|
15761
15713
|
addDefault(importedSourceIn, opts) {
|
15762
15714
|
return this.addNamed("default", importedSourceIn, opts);
|
15763
15715
|
}
|
15764
|
-
|
15765
15716
|
addNamed(importName, importedSourceIn, opts) {
|
15766
15717
|
_assert(typeof importName === "string");
|
15767
|
-
|
15768
15718
|
return this._generateImport(this._applyDefaults(importedSourceIn, opts), importName);
|
15769
15719
|
}
|
15770
|
-
|
15771
15720
|
addNamespace(importedSourceIn, opts) {
|
15772
15721
|
return this._generateImport(this._applyDefaults(importedSourceIn, opts), null);
|
15773
15722
|
}
|
15774
|
-
|
15775
15723
|
addSideEffect(importedSourceIn, opts) {
|
15776
15724
|
return this._generateImport(this._applyDefaults(importedSourceIn, opts), void 0);
|
15777
15725
|
}
|
15778
|
-
|
15779
15726
|
_applyDefaults(importedSource, opts, isInit = false) {
|
15780
15727
|
let newOpts;
|
15781
|
-
|
15782
15728
|
if (typeof importedSource === "string") {
|
15783
15729
|
newOpts = Object.assign({}, this._defaultOpts, {
|
15784
15730
|
importedSource
|
15785
15731
|
}, opts);
|
15786
15732
|
} else {
|
15787
15733
|
_assert(!opts, "Unexpected secondary arguments.");
|
15788
|
-
|
15789
15734
|
newOpts = Object.assign({}, this._defaultOpts, importedSource);
|
15790
15735
|
}
|
15791
|
-
|
15792
15736
|
if (!isInit && opts) {
|
15793
15737
|
if (opts.nameHint !== undefined) newOpts.nameHint = opts.nameHint;
|
15794
15738
|
if (opts.blockHoist !== undefined) newOpts.blockHoist = opts.blockHoist;
|
15795
15739
|
}
|
15796
|
-
|
15797
15740
|
return newOpts;
|
15798
15741
|
}
|
15799
|
-
|
15800
15742
|
_generateImport(opts, importName) {
|
15801
15743
|
const isDefault = importName === "default";
|
15802
15744
|
const isNamed = !!importName && !isDefault;
|
@@ -15816,20 +15758,15 @@ class ImportInjector {
|
|
15816
15758
|
const isMod = (0, _isModule.default)(this._programPath);
|
15817
15759
|
const isModuleForNode = isMod && importingInterop === "node";
|
15818
15760
|
const isModuleForBabel = isMod && importingInterop === "babel";
|
15819
|
-
|
15820
15761
|
if (importPosition === "after" && !isMod) {
|
15821
15762
|
throw new Error(`"importPosition": "after" is only supported in modules`);
|
15822
15763
|
}
|
15823
|
-
|
15824
15764
|
const builder = new _importBuilder.default(importedSource, this._programScope, this._hub);
|
15825
|
-
|
15826
15765
|
if (importedType === "es6") {
|
15827
15766
|
if (!isModuleForNode && !isModuleForBabel) {
|
15828
15767
|
throw new Error("Cannot import an ES6 module from CommonJS");
|
15829
15768
|
}
|
15830
|
-
|
15831
15769
|
builder.import();
|
15832
|
-
|
15833
15770
|
if (isNamespace) {
|
15834
15771
|
builder.namespace(nameHint || importedSource);
|
15835
15772
|
} else if (isDefault || isNamed) {
|
@@ -15842,7 +15779,6 @@ class ImportInjector {
|
|
15842
15779
|
name = name !== "default" ? name : importedSource;
|
15843
15780
|
const es6Default = `${importedSource}$es6Default`;
|
15844
15781
|
builder.import();
|
15845
|
-
|
15846
15782
|
if (isNamespace) {
|
15847
15783
|
builder.default(es6Default).var(name || importedSource).wildcardInterop();
|
15848
15784
|
} else if (isDefault) {
|
@@ -15856,7 +15792,6 @@ class ImportInjector {
|
|
15856
15792
|
}
|
15857
15793
|
} else if (isModuleForBabel) {
|
15858
15794
|
builder.import();
|
15859
|
-
|
15860
15795
|
if (isNamespace) {
|
15861
15796
|
builder.namespace(name || importedSource);
|
15862
15797
|
} else if (isDefault || isNamed) {
|
@@ -15864,7 +15799,6 @@ class ImportInjector {
|
|
15864
15799
|
}
|
15865
15800
|
} else {
|
15866
15801
|
builder.require();
|
15867
|
-
|
15868
15802
|
if (isNamespace) {
|
15869
15803
|
builder.var(name || importedSource).wildcardInterop();
|
15870
15804
|
} else if ((isDefault || isNamed) && ensureLiveReference) {
|
@@ -15884,7 +15818,6 @@ class ImportInjector {
|
|
15884
15818
|
} else if (importedInterop === "compiled") {
|
15885
15819
|
if (isModuleForNode) {
|
15886
15820
|
builder.import();
|
15887
|
-
|
15888
15821
|
if (isNamespace) {
|
15889
15822
|
builder.default(name || importedSource);
|
15890
15823
|
} else if (isDefault || isNamed) {
|
@@ -15892,7 +15825,6 @@ class ImportInjector {
|
|
15892
15825
|
}
|
15893
15826
|
} else if (isModuleForBabel) {
|
15894
15827
|
builder.import();
|
15895
|
-
|
15896
15828
|
if (isNamespace) {
|
15897
15829
|
builder.namespace(name || importedSource);
|
15898
15830
|
} else if (isDefault || isNamed) {
|
@@ -15900,7 +15832,6 @@ class ImportInjector {
|
|
15900
15832
|
}
|
15901
15833
|
} else {
|
15902
15834
|
builder.require();
|
15903
|
-
|
15904
15835
|
if (isNamespace) {
|
15905
15836
|
builder.var(name || importedSource);
|
15906
15837
|
} else if (isDefault || isNamed) {
|
@@ -15915,10 +15846,8 @@ class ImportInjector {
|
|
15915
15846
|
if (isDefault && ensureLiveReference) {
|
15916
15847
|
throw new Error("No live reference for commonjs default");
|
15917
15848
|
}
|
15918
|
-
|
15919
15849
|
if (isModuleForNode) {
|
15920
15850
|
builder.import();
|
15921
|
-
|
15922
15851
|
if (isNamespace) {
|
15923
15852
|
builder.default(name || importedSource);
|
15924
15853
|
} else if (isDefault) {
|
@@ -15928,7 +15857,6 @@ class ImportInjector {
|
|
15928
15857
|
}
|
15929
15858
|
} else if (isModuleForBabel) {
|
15930
15859
|
builder.import();
|
15931
|
-
|
15932
15860
|
if (isNamespace) {
|
15933
15861
|
builder.default(name || importedSource);
|
15934
15862
|
} else if (isDefault) {
|
@@ -15938,7 +15866,6 @@ class ImportInjector {
|
|
15938
15866
|
}
|
15939
15867
|
} else {
|
15940
15868
|
builder.require();
|
15941
|
-
|
15942
15869
|
if (isNamespace) {
|
15943
15870
|
builder.var(name || importedSource);
|
15944
15871
|
} else if (isDefault) {
|
@@ -15954,24 +15881,18 @@ class ImportInjector {
|
|
15954
15881
|
} else {
|
15955
15882
|
throw new Error(`Unknown importedInterop "${importedInterop}".`);
|
15956
15883
|
}
|
15957
|
-
|
15958
15884
|
const {
|
15959
15885
|
statements,
|
15960
15886
|
resultName
|
15961
15887
|
} = builder.done();
|
15962
|
-
|
15963
15888
|
this._insertStatements(statements, importPosition, blockHoist);
|
15964
|
-
|
15965
15889
|
if ((isDefault || isNamed) && ensureNoContext && resultName.type !== "Identifier") {
|
15966
15890
|
return sequenceExpression([numericLiteral(0), resultName]);
|
15967
15891
|
}
|
15968
|
-
|
15969
15892
|
return resultName;
|
15970
15893
|
}
|
15971
|
-
|
15972
15894
|
_insertStatements(statements, importPosition = "before", blockHoist = 3) {
|
15973
15895
|
const body = this._programPath.get("body");
|
15974
|
-
|
15975
15896
|
if (importPosition === "after") {
|
15976
15897
|
for (let i = body.length - 1; i >= 0; i--) {
|
15977
15898
|
if (body[i].isImportDeclaration()) {
|
@@ -15987,23 +15908,22 @@ class ImportInjector {
|
|
15987
15908
|
const val = p.node._blockHoist;
|
15988
15909
|
return Number.isFinite(val) && val < 4;
|
15989
15910
|
});
|
15990
|
-
|
15991
15911
|
if (targetPath) {
|
15992
15912
|
targetPath.insertBefore(statements);
|
15993
15913
|
return;
|
15994
15914
|
}
|
15995
15915
|
}
|
15996
|
-
|
15997
15916
|
this._programPath.unshiftContainer("body", statements);
|
15998
15917
|
}
|
15999
|
-
|
16000
15918
|
}
|
16001
|
-
|
16002
15919
|
exports.default = ImportInjector;
|
16003
15920
|
|
15921
|
+
//# sourceMappingURL=import-injector.js.map
|
15922
|
+
|
15923
|
+
|
16004
15924
|
/***/ }),
|
16005
15925
|
|
16006
|
-
/***/
|
15926
|
+
/***/ 10742:
|
16007
15927
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
16008
15928
|
|
16009
15929
|
"use strict";
|
@@ -16028,30 +15948,27 @@ Object.defineProperty(exports, "isModule", ({
|
|
16028
15948
|
return _isModule.default;
|
16029
15949
|
}
|
16030
15950
|
}));
|
16031
|
-
|
16032
|
-
var
|
16033
|
-
|
16034
|
-
var _isModule = __webpack_require__(77901);
|
16035
|
-
|
15951
|
+
var _importInjector = __webpack_require__(37615);
|
15952
|
+
var _isModule = __webpack_require__(59462);
|
16036
15953
|
function addDefault(path, importedSource, opts) {
|
16037
15954
|
return new _importInjector.default(path).addDefault(importedSource, opts);
|
16038
15955
|
}
|
16039
|
-
|
16040
15956
|
function addNamed(path, name, importedSource, opts) {
|
16041
15957
|
return new _importInjector.default(path).addNamed(name, importedSource, opts);
|
16042
15958
|
}
|
16043
|
-
|
16044
15959
|
function addNamespace(path, importedSource, opts) {
|
16045
15960
|
return new _importInjector.default(path).addNamespace(importedSource, opts);
|
16046
15961
|
}
|
16047
|
-
|
16048
15962
|
function addSideEffect(path, importedSource, opts) {
|
16049
15963
|
return new _importInjector.default(path).addSideEffect(importedSource, opts);
|
16050
15964
|
}
|
16051
15965
|
|
15966
|
+
//# sourceMappingURL=index.js.map
|
15967
|
+
|
15968
|
+
|
16052
15969
|
/***/ }),
|
16053
15970
|
|
16054
|
-
/***/
|
15971
|
+
/***/ 59462:
|
16055
15972
|
/***/ ((__unused_webpack_module, exports) => {
|
16056
15973
|
|
16057
15974
|
"use strict";
|
@@ -16061,19 +15978,13 @@ Object.defineProperty(exports, "__esModule", ({
|
|
16061
15978
|
value: true
|
16062
15979
|
}));
|
16063
15980
|
exports.default = isModule;
|
16064
|
-
|
16065
15981
|
function isModule(path) {
|
16066
|
-
const {
|
16067
|
-
sourceType
|
16068
|
-
} = path.node;
|
16069
|
-
|
16070
|
-
if (sourceType !== "module" && sourceType !== "script") {
|
16071
|
-
throw path.buildCodeFrameError(`Unknown sourceType "${sourceType}", cannot transform.`);
|
16072
|
-
}
|
16073
|
-
|
16074
15982
|
return path.node.sourceType === "module";
|
16075
15983
|
}
|
16076
15984
|
|
15985
|
+
//# sourceMappingURL=is-module.js.map
|
15986
|
+
|
15987
|
+
|
16077
15988
|
/***/ }),
|
16078
15989
|
|
16079
15990
|
/***/ 40380:
|
@@ -16252,7 +16163,7 @@ exports.wrapInterop = wrapInterop;
|
|
16252
16163
|
var _assert = __webpack_require__(42357);
|
16253
16164
|
var _t = __webpack_require__(32338);
|
16254
16165
|
var _template = __webpack_require__(82272);
|
16255
|
-
var _helperModuleImports = __webpack_require__(
|
16166
|
+
var _helperModuleImports = __webpack_require__(10742);
|
16256
16167
|
var _rewriteThis = __webpack_require__(52831);
|
16257
16168
|
var _rewriteLiveReferences = __webpack_require__(72337);
|
16258
16169
|
var _normalizeAndLoadMetadata = __webpack_require__(34376);
|
@@ -140038,17 +139949,12 @@ const path_1 = __webpack_require__(85622);
|
|
140038
139949
|
function forkDevServer(options) {
|
140039
139950
|
let nodeOptions = process.env.NODE_OPTIONS;
|
140040
139951
|
const tsNodePath = options.require_.resolve('ts-node');
|
140041
|
-
const esmLoader = url_1.pathToFileURL(path_1.join(tsNodePath, '..', '..', 'esm.mjs'));
|
140042
|
-
const cjsLoader = path_1.join(tsNodePath, '..', '..', 'register', 'index.js');
|
140043
|
-
const devServerPath = options.devServerPath || path_1.join(__dirname, 'dev-server.
|
139952
|
+
const esmLoader = (0, url_1.pathToFileURL)((0, path_1.join)(tsNodePath, '..', '..', 'esm.mjs'));
|
139953
|
+
const cjsLoader = (0, path_1.join)(tsNodePath, '..', '..', 'register', 'index.js');
|
139954
|
+
const devServerPath = options.devServerPath || (0, path_1.join)(__dirname, 'dev-server.mjs');
|
140044
139955
|
if (options.maybeTranspile) {
|
140045
139956
|
if (options.isTypeScript) {
|
140046
|
-
|
140047
|
-
nodeOptions = `--loader ${esmLoader} ${nodeOptions || ''}`;
|
140048
|
-
}
|
140049
|
-
else {
|
140050
|
-
nodeOptions = `--require ${cjsLoader} ${nodeOptions || ''}`;
|
140051
|
-
}
|
139957
|
+
nodeOptions = `--loader ${esmLoader} ${nodeOptions || ''}`;
|
140052
139958
|
}
|
140053
139959
|
else {
|
140054
139960
|
if (options.isEsm) {
|
@@ -140062,9 +139968,8 @@ function forkDevServer(options) {
|
|
140062
139968
|
const forkOptions = {
|
140063
139969
|
cwd: options.workPath,
|
140064
139970
|
execArgv: [],
|
140065
|
-
env: build_utils_1.cloneEnv(process.env, options.meta.env, {
|
139971
|
+
env: (0, build_utils_1.cloneEnv)(process.env, options.meta.env, {
|
140066
139972
|
VERCEL_DEV_ENTRYPOINT: options.entrypoint,
|
140067
|
-
VERCEL_DEV_IS_ESM: options.isEsm ? '1' : undefined,
|
140068
139973
|
VERCEL_DEV_CONFIG: JSON.stringify(options.config),
|
140069
139974
|
VERCEL_DEV_BUILD_ENV: JSON.stringify(options.meta.buildEnv || {}),
|
140070
139975
|
TS_NODE_TRANSPILE_ONLY: '1',
|
@@ -140074,7 +139979,7 @@ function forkDevServer(options) {
|
|
140074
139979
|
NODE_OPTIONS: nodeOptions,
|
140075
139980
|
}),
|
140076
139981
|
};
|
140077
|
-
const child = child_process_1.fork(devServerPath, [], forkOptions);
|
139982
|
+
const child = (0, child_process_1.fork)(devServerPath, [], forkOptions);
|
140078
139983
|
checkForPid(devServerPath, child);
|
140079
139984
|
return child;
|
140080
139985
|
}
|
@@ -140090,7 +139995,7 @@ function checkForPid(path, process) {
|
|
140090
139995
|
* or it is listening to new requests, and we can start proxying requests.
|
140091
139996
|
*/
|
140092
139997
|
async function readMessage(child) {
|
140093
|
-
const onMessage = once_1.default(child, 'message');
|
139998
|
+
const onMessage = (0, once_1.default)(child, 'message');
|
140094
139999
|
const onExit = once_1.default.spread(child, 'close');
|
140095
140000
|
const result = await Promise.race([
|
140096
140001
|
onMessage.then(x => {
|
@@ -140116,7 +140021,11 @@ exports.readMessage = readMessage;
|
|
140116
140021
|
|
140117
140022
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
140118
140023
|
if (k2 === undefined) k2 = k;
|
140119
|
-
Object.
|
140024
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
140025
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
140026
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
140027
|
+
}
|
140028
|
+
Object.defineProperty(o, k2, desc);
|
140120
140029
|
}) : (function(o, m, k, k2) {
|
140121
140030
|
if (k2 === undefined) k2 = k;
|
140122
140031
|
o[k2] = m[k];
|
@@ -140129,6 +140038,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
140129
140038
|
};
|
140130
140039
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
140131
140040
|
exports.startDevServer = exports.prepareCache = exports.build = exports.version = exports.shouldServe = void 0;
|
140041
|
+
const error_utils_1 = __webpack_require__(27915);
|
140132
140042
|
const url_1 = __importDefault(__webpack_require__(78835));
|
140133
140043
|
const child_process_1 = __webpack_require__(63129);
|
140134
140044
|
const fs_1 = __webpack_require__(35747);
|
@@ -140145,15 +140055,15 @@ const utils_1 = __webpack_require__(76136);
|
|
140145
140055
|
const fork_dev_server_1 = __webpack_require__(31158);
|
140146
140056
|
const ALLOWED_RUNTIMES = ['nodejs', ...Object.values(utils_1.EdgeRuntimes)];
|
140147
140057
|
const require_ = eval('require');
|
140148
|
-
const tscPath = path_1.resolve(path_1.dirname(require_.resolve('typescript')), '../bin/tsc');
|
140058
|
+
const tscPath = (0, path_1.resolve)((0, path_1.dirname)(require_.resolve('typescript')), '../bin/tsc');
|
140149
140059
|
// eslint-disable-next-line no-useless-escape
|
140150
140060
|
const libPathRegEx = /^node_modules|[\/\\]node_modules[\/\\]/;
|
140151
140061
|
async function downloadInstallAndBundle({ files, entrypoint, workPath, config, meta, }) {
|
140152
|
-
const downloadedFiles = await build_utils_1.download(files, workPath, meta);
|
140153
|
-
const entrypointFsDirname = path_1.join(workPath, path_1.dirname(entrypoint));
|
140154
|
-
const nodeVersion = await build_utils_1.getNodeVersion(entrypointFsDirname, undefined, config, meta);
|
140155
|
-
const spawnOpts = build_utils_1.getSpawnOptions(meta, nodeVersion);
|
140156
|
-
await build_utils_1.runNpmInstall(entrypointFsDirname, [], spawnOpts, meta, nodeVersion);
|
140062
|
+
const downloadedFiles = await (0, build_utils_1.download)(files, workPath, meta);
|
140063
|
+
const entrypointFsDirname = (0, path_1.join)(workPath, (0, path_1.dirname)(entrypoint));
|
140064
|
+
const nodeVersion = await (0, build_utils_1.getNodeVersion)(entrypointFsDirname, undefined, config, meta);
|
140065
|
+
const spawnOpts = (0, build_utils_1.getSpawnOptions)(meta, nodeVersion);
|
140066
|
+
await (0, build_utils_1.runNpmInstall)(entrypointFsDirname, [], spawnOpts, meta, nodeVersion);
|
140157
140067
|
const entrypointPath = downloadedFiles[entrypoint].fsPath;
|
140158
140068
|
return { entrypointPath, entrypointFsDirname, nodeVersion, spawnOpts };
|
140159
140069
|
}
|
@@ -140179,10 +140089,10 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
|
|
140179
140089
|
? [config.includeFiles]
|
140180
140090
|
: config.includeFiles;
|
140181
140091
|
for (const pattern of includeFiles) {
|
140182
|
-
const files = await build_utils_1.glob(pattern, workPath);
|
140092
|
+
const files = await (0, build_utils_1.glob)(pattern, workPath);
|
140183
140093
|
await Promise.all(Object.values(files).map(async (entry) => {
|
140184
140094
|
const { fsPath } = entry;
|
140185
|
-
const relPath = path_1.relative(baseDir, fsPath);
|
140095
|
+
const relPath = (0, path_1.relative)(baseDir, fsPath);
|
140186
140096
|
fsCache.set(relPath, entry);
|
140187
140097
|
preparedFiles[relPath] = entry;
|
140188
140098
|
}));
|
@@ -140190,9 +140100,9 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
|
|
140190
140100
|
}
|
140191
140101
|
let tsCompile;
|
140192
140102
|
function compileTypeScript(path, source) {
|
140193
|
-
const relPath = path_1.relative(baseDir, path);
|
140103
|
+
const relPath = (0, path_1.relative)(baseDir, path);
|
140194
140104
|
if (!tsCompile) {
|
140195
|
-
tsCompile = typescript_1.register({
|
140105
|
+
tsCompile = (0, typescript_1.register)({
|
140196
140106
|
basePath: workPath,
|
140197
140107
|
project: path,
|
140198
140108
|
files: true,
|
@@ -140211,7 +140121,7 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
|
|
140211
140121
|
const conditions = isEdgeFunction
|
140212
140122
|
? ['edge-light', 'browser', 'module', 'import', 'require']
|
140213
140123
|
: undefined;
|
140214
|
-
const { fileList, esmFileList, warnings } = await nft_1.nodeFileTrace([...inputFiles], {
|
140124
|
+
const { fileList, esmFileList, warnings } = await (0, nft_1.nodeFileTrace)([...inputFiles], {
|
140215
140125
|
base: baseDir,
|
140216
140126
|
processCwd: workPath,
|
140217
140127
|
ts: true,
|
@@ -140219,29 +140129,29 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
|
|
140219
140129
|
conditions,
|
140220
140130
|
resolve(id, parent, job, cjsResolve) {
|
140221
140131
|
const normalizedWasmImports = id.replace(/\.wasm\?module$/i, '.wasm');
|
140222
|
-
return resolve_dependency_1.default(normalizedWasmImports, parent, job, cjsResolve);
|
140132
|
+
return (0, resolve_dependency_1.default)(normalizedWasmImports, parent, job, cjsResolve);
|
140223
140133
|
},
|
140224
140134
|
ignore: config.excludeFiles,
|
140225
140135
|
async readFile(fsPath) {
|
140226
|
-
const relPath = path_1.relative(baseDir, fsPath);
|
140136
|
+
const relPath = (0, path_1.relative)(baseDir, fsPath);
|
140227
140137
|
// If this file has already been read then return from the cache
|
140228
140138
|
const cached = sourceCache.get(relPath);
|
140229
140139
|
if (typeof cached !== 'undefined')
|
140230
140140
|
return cached;
|
140231
140141
|
try {
|
140232
140142
|
let entry;
|
140233
|
-
let source = fs_1.readFileSync(fsPath);
|
140234
|
-
const { mode } = fs_1.lstatSync(fsPath);
|
140235
|
-
if (build_utils_1.isSymbolicLink(mode)) {
|
140143
|
+
let source = (0, fs_1.readFileSync)(fsPath);
|
140144
|
+
const { mode } = (0, fs_1.lstatSync)(fsPath);
|
140145
|
+
if ((0, build_utils_1.isSymbolicLink)(mode)) {
|
140236
140146
|
entry = new build_utils_1.FileFsRef({ fsPath, mode });
|
140237
140147
|
}
|
140238
|
-
if (isEdgeFunction && path_1.basename(fsPath) === 'package.json') {
|
140148
|
+
if (isEdgeFunction && (0, path_1.basename)(fsPath) === 'package.json') {
|
140239
140149
|
// For Edge Functions, patch "main" field to prefer "browser" or "module"
|
140240
140150
|
const pkgJson = JSON.parse(source.toString());
|
140241
140151
|
for (const prop of ['browser', 'module']) {
|
140242
140152
|
const val = pkgJson[prop];
|
140243
140153
|
if (typeof val === 'string') {
|
140244
|
-
build_utils_1.debug(`Using "${prop}" field in ${fsPath}`);
|
140154
|
+
(0, build_utils_1.debug)(`Using "${prop}" field in ${fsPath}`);
|
140245
140155
|
pkgJson.main = val;
|
140246
140156
|
// Create the `entry` with the original so that the output is unmodified
|
140247
140157
|
if (!entry) {
|
@@ -140264,38 +140174,39 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
|
|
140264
140174
|
sourceCache.set(relPath, source);
|
140265
140175
|
return source;
|
140266
140176
|
}
|
140267
|
-
catch (
|
140268
|
-
if (
|
140177
|
+
catch (error) {
|
140178
|
+
if ((0, error_utils_1.isErrnoException)(error) &&
|
140179
|
+
(error.code === 'ENOENT' || error.code === 'EISDIR')) {
|
140269
140180
|
// `null` represents a not found
|
140270
140181
|
sourceCache.set(relPath, null);
|
140271
140182
|
return null;
|
140272
140183
|
}
|
140273
|
-
throw
|
140184
|
+
throw error;
|
140274
140185
|
}
|
140275
140186
|
},
|
140276
140187
|
});
|
140277
140188
|
for (const warning of warnings) {
|
140278
|
-
build_utils_1.debug(`Warning from trace: ${warning.message}`);
|
140189
|
+
(0, build_utils_1.debug)(`Warning from trace: ${warning.message}`);
|
140279
140190
|
}
|
140280
140191
|
for (const path of fileList) {
|
140281
140192
|
let entry = fsCache.get(path);
|
140282
140193
|
if (!entry) {
|
140283
|
-
const fsPath = path_1.resolve(baseDir, path);
|
140284
|
-
const { mode } = fs_1.lstatSync(fsPath);
|
140285
|
-
if (build_utils_1.isSymbolicLink(mode)) {
|
140194
|
+
const fsPath = (0, path_1.resolve)(baseDir, path);
|
140195
|
+
const { mode } = (0, fs_1.lstatSync)(fsPath);
|
140196
|
+
if ((0, build_utils_1.isSymbolicLink)(mode)) {
|
140286
140197
|
entry = new build_utils_1.FileFsRef({ fsPath, mode });
|
140287
140198
|
}
|
140288
140199
|
else {
|
140289
|
-
const source = fs_1.readFileSync(fsPath);
|
140200
|
+
const source = (0, fs_1.readFileSync)(fsPath);
|
140290
140201
|
entry = new build_utils_1.FileBlob({ data: source, mode });
|
140291
140202
|
}
|
140292
140203
|
}
|
140293
|
-
if (build_utils_1.isSymbolicLink(entry.mode) && entry.type === 'FileFsRef') {
|
140204
|
+
if ((0, build_utils_1.isSymbolicLink)(entry.mode) && entry.type === 'FileFsRef') {
|
140294
140205
|
// ensure the symlink target is added to the file list
|
140295
|
-
const symlinkTarget = path_1.relative(baseDir, path_1.resolve(path_1.dirname(entry.fsPath), fs_1.readlinkSync(entry.fsPath)));
|
140206
|
+
const symlinkTarget = (0, path_1.relative)(baseDir, (0, path_1.resolve)((0, path_1.dirname)(entry.fsPath), (0, fs_1.readlinkSync)(entry.fsPath)));
|
140296
140207
|
if (!symlinkTarget.startsWith('..' + path_1.sep) &&
|
140297
140208
|
!fileList.has(symlinkTarget)) {
|
140298
|
-
const stats = fs_1.statSync(path_1.resolve(baseDir, symlinkTarget));
|
140209
|
+
const stats = (0, fs_1.statSync)((0, path_1.resolve)(baseDir, symlinkTarget));
|
140299
140210
|
if (stats.isFile()) {
|
140300
140211
|
fileList.add(symlinkTarget);
|
140301
140212
|
}
|
@@ -140316,9 +140227,9 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
|
|
140316
140227
|
if (esmPaths.length) {
|
140317
140228
|
const babelCompile = __webpack_require__(20007)/* .compile */ .M;
|
140318
140229
|
for (const path of esmPaths) {
|
140319
|
-
const pathDir = path_1.join(workPath, path_1.dirname(path));
|
140230
|
+
const pathDir = (0, path_1.join)(workPath, (0, path_1.dirname)(path));
|
140320
140231
|
if (!pkgCache.has(pathDir)) {
|
140321
|
-
const pathToPkg = await build_utils_1.walkParentDirs({
|
140232
|
+
const pathToPkg = await (0, build_utils_1.walkParentDirs)({
|
140322
140233
|
base: workPath,
|
140323
140234
|
start: pathDir,
|
140324
140235
|
filename: 'package.json',
|
@@ -140333,7 +140244,7 @@ async function compile(workPath, baseDir, entrypointPath, config, nodeVersion, i
|
|
140333
140244
|
// https://nodejs.org/api/packages.html#packages_type
|
140334
140245
|
continue;
|
140335
140246
|
}
|
140336
|
-
const filename = path_1.basename(path);
|
140247
|
+
const filename = (0, path_1.basename)(path);
|
140337
140248
|
const { data: source } = await build_utils_1.FileBlob.fromStream({
|
140338
140249
|
stream: preparedFiles[path].toStream(),
|
140339
140250
|
});
|
@@ -140358,7 +140269,7 @@ function getAWSLambdaHandler(entrypoint, config) {
|
|
140358
140269
|
return config.awsLambdaHandler;
|
140359
140270
|
}
|
140360
140271
|
if (process.env.NODEJS_AWS_HANDLER_NAME) {
|
140361
|
-
const { dir, name } = path_1.parse(entrypoint);
|
140272
|
+
const { dir, name } = (0, path_1.parse)(entrypoint);
|
140362
140273
|
return `${dir}${dir ? path_1.sep : ''}${name}.${process.env.NODEJS_AWS_HANDLER_NAME}`;
|
140363
140274
|
}
|
140364
140275
|
return '';
|
@@ -140376,7 +140287,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
140376
140287
|
config,
|
140377
140288
|
meta,
|
140378
140289
|
});
|
140379
|
-
await build_utils_1.runPackageJsonScript(entrypointFsDirname,
|
140290
|
+
await (0, build_utils_1.runPackageJsonScript)(entrypointFsDirname,
|
140380
140291
|
// Don't consider "build" script since its intended for frontend code
|
140381
140292
|
['vercel-build', 'now-build'], spawnOpts);
|
140382
140293
|
const isMiddleware = config.middleware === true;
|
@@ -140385,7 +140296,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
140385
140296
|
// `export const config = { runtime: 'edge' }`
|
140386
140297
|
let isEdgeFunction = isMiddleware;
|
140387
140298
|
const project = new ts_morph_1.Project();
|
140388
|
-
const staticConfig = static_config_1.getConfig(project, entrypointPath);
|
140299
|
+
const staticConfig = (0, static_config_1.getConfig)(project, entrypointPath);
|
140389
140300
|
if (staticConfig?.runtime) {
|
140390
140301
|
if (!ALLOWED_RUNTIMES.includes(staticConfig.runtime)) {
|
140391
140302
|
throw new Error(`Unsupported "runtime" property in \`config\`: ${JSON.stringify(staticConfig.runtime)} (must be one of: ${JSON.stringify(ALLOWED_RUNTIMES)})`);
|
@@ -140393,16 +140304,16 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
140393
140304
|
if (staticConfig.runtime === 'nodejs') {
|
140394
140305
|
console.log(`Detected unused static config runtime "nodejs" in "${entrypointPath}"`);
|
140395
140306
|
}
|
140396
|
-
isEdgeFunction = utils_1.isEdgeRuntime(staticConfig.runtime);
|
140307
|
+
isEdgeFunction = (0, utils_1.isEdgeRuntime)(staticConfig.runtime);
|
140397
140308
|
}
|
140398
|
-
build_utils_1.debug('Tracing input files...');
|
140309
|
+
(0, build_utils_1.debug)('Tracing input files...');
|
140399
140310
|
const traceTime = Date.now();
|
140400
140311
|
const { preparedFiles, shouldAddSourcemapSupport } = await compile(workPath, baseDir, entrypointPath, config, nodeVersion, isEdgeFunction);
|
140401
|
-
build_utils_1.debug(`Trace complete [${Date.now() - traceTime}ms]`);
|
140312
|
+
(0, build_utils_1.debug)(`Trace complete [${Date.now() - traceTime}ms]`);
|
140402
140313
|
let routes;
|
140403
140314
|
let output;
|
140404
|
-
const handler = renameTStoJS(path_1.relative(baseDir, entrypointPath));
|
140405
|
-
const outputPath = utils_1.entrypointToOutputPath(entrypoint, config.zeroConfig);
|
140315
|
+
const handler = renameTStoJS((0, path_1.relative)(baseDir, entrypointPath));
|
140316
|
+
const outputPath = (0, utils_1.entrypointToOutputPath)(entrypoint, config.zeroConfig);
|
140406
140317
|
// Add a `route` for Middleware
|
140407
140318
|
if (isMiddleware) {
|
140408
140319
|
if (!isEdgeFunction) {
|
@@ -140410,7 +140321,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
140410
140321
|
throw new Error(`Middleware file can not be a Node.js Serverless Function`);
|
140411
140322
|
}
|
140412
140323
|
// Middleware is a catch-all for all paths unless a `matcher` property is defined
|
140413
|
-
const src = utils_1.getRegExpFromMatchers(staticConfig?.matcher);
|
140324
|
+
const src = (0, utils_1.getRegExpFromMatchers)(staticConfig?.matcher);
|
140414
140325
|
const middlewareRawSrc = [];
|
140415
140326
|
if (staticConfig?.matcher) {
|
140416
140327
|
if (Array.isArray(staticConfig.matcher)) {
|
@@ -140461,19 +140372,19 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
140461
140372
|
};
|
140462
140373
|
exports.build = build;
|
140463
140374
|
const prepareCache = ({ repoRootPath, workPath }) => {
|
140464
|
-
return build_utils_1.glob('**/node_modules/**', repoRootPath || workPath);
|
140375
|
+
return (0, build_utils_1.glob)('**/node_modules/**', repoRootPath || workPath);
|
140465
140376
|
};
|
140466
140377
|
exports.prepareCache = prepareCache;
|
140467
140378
|
const startDevServer = async (opts) => {
|
140468
140379
|
const { entrypoint, workPath, config, meta = {} } = opts;
|
140469
|
-
const entrypointPath = path_1.join(workPath, entrypoint);
|
140380
|
+
const entrypointPath = (0, path_1.join)(workPath, entrypoint);
|
140470
140381
|
if (config.middleware === true && typeof meta.requestUrl === 'string') {
|
140471
140382
|
// TODO: static config is also parsed in `dev-server.ts`.
|
140472
140383
|
// we should pass in this version as an env var instead.
|
140473
140384
|
const project = new ts_morph_1.Project();
|
140474
|
-
const staticConfig = static_config_1.getConfig(project, entrypointPath);
|
140385
|
+
const staticConfig = (0, static_config_1.getConfig)(project, entrypointPath);
|
140475
140386
|
// Middleware is a catch-all for all paths unless a `matcher` property is defined
|
140476
|
-
const matchers = new RegExp(utils_1.getRegExpFromMatchers(staticConfig?.matcher));
|
140387
|
+
const matchers = new RegExp((0, utils_1.getRegExpFromMatchers)(staticConfig?.matcher));
|
140477
140388
|
const parsed = url_1.default.parse(meta.requestUrl, true);
|
140478
140389
|
if (typeof parsed.pathname !== 'string' ||
|
140479
140390
|
!matchers.test(parsed.pathname)) {
|
@@ -140482,21 +140393,21 @@ const startDevServer = async (opts) => {
|
|
140482
140393
|
return null;
|
140483
140394
|
}
|
140484
140395
|
}
|
140485
|
-
const entryDir = path_1.dirname(entrypointPath);
|
140486
|
-
const ext = path_1.extname(entrypoint);
|
140487
|
-
const pathToTsConfig = await build_utils_1.walkParentDirs({
|
140396
|
+
const entryDir = (0, path_1.dirname)(entrypointPath);
|
140397
|
+
const ext = (0, path_1.extname)(entrypoint);
|
140398
|
+
const pathToTsConfig = await (0, build_utils_1.walkParentDirs)({
|
140488
140399
|
base: workPath,
|
140489
140400
|
start: entryDir,
|
140490
140401
|
filename: 'tsconfig.json',
|
140491
140402
|
});
|
140492
|
-
const pathToPkg = await build_utils_1.walkParentDirs({
|
140403
|
+
const pathToPkg = await (0, build_utils_1.walkParentDirs)({
|
140493
140404
|
base: workPath,
|
140494
140405
|
start: entryDir,
|
140495
140406
|
filename: 'package.json',
|
140496
140407
|
});
|
140497
140408
|
const pkg = pathToPkg ? require_(pathToPkg) : {};
|
140498
|
-
const
|
140499
|
-
const maybeTranspile =
|
140409
|
+
const isTypeScript = ['.ts', '.tsx', '.mts', '.cts'].includes(ext);
|
140410
|
+
const maybeTranspile = isTypeScript || !['.cjs', '.mjs'].includes(ext);
|
140500
140411
|
const isEsm = ext === '.mjs' ||
|
140501
140412
|
ext === '.mts' ||
|
140502
140413
|
(pkg.type === 'module' && ['.js', '.ts', '.tsx'].includes(ext));
|
@@ -140521,22 +140432,35 @@ const startDevServer = async (opts) => {
|
|
140521
140432
|
}
|
140522
140433
|
// Otherwise fall back to using the copy that `@vercel/node` uses
|
140523
140434
|
if (!ts) {
|
140524
|
-
compiler = resolveTypescript(path_1.join(__dirname, '..'));
|
140435
|
+
compiler = resolveTypescript((0, path_1.join)(__dirname, '..'));
|
140525
140436
|
ts = requireTypescript(compiler);
|
140526
140437
|
}
|
140527
140438
|
if (pathToTsConfig) {
|
140528
140439
|
try {
|
140529
140440
|
tsConfig = ts.readConfigFile(pathToTsConfig, ts.sys.readFile).config;
|
140530
140441
|
}
|
140531
|
-
catch (
|
140532
|
-
if (
|
140442
|
+
catch (error) {
|
140443
|
+
if ((0, error_utils_1.isErrnoException)(error) && error.code !== 'ENOENT') {
|
140533
140444
|
console.error(`Error while parsing "${pathToTsConfig}"`);
|
140534
|
-
throw
|
140445
|
+
throw error;
|
140535
140446
|
}
|
140536
140447
|
}
|
140537
140448
|
}
|
140449
|
+
// if we're using ESM, we need to tell TypeScript to use `nodenext` to
|
140450
|
+
// preserve the `import` semantics
|
140451
|
+
if (isEsm) {
|
140452
|
+
if (!tsConfig.compilerOptions) {
|
140453
|
+
tsConfig.compilerOptions = {};
|
140454
|
+
}
|
140455
|
+
if (tsConfig.compilerOptions.module === undefined) {
|
140456
|
+
tsConfig.compilerOptions.module = 'nodenext';
|
140457
|
+
}
|
140458
|
+
if (tsConfig.compilerOptions.moduleResolution === undefined) {
|
140459
|
+
tsConfig.compilerOptions.moduleResolution = 'nodenext';
|
140460
|
+
}
|
140461
|
+
}
|
140538
140462
|
const nodeVersionMajor = Number(process.versions.node.split('.')[0]);
|
140539
|
-
typescript_1.fixConfig(tsConfig, nodeVersionMajor);
|
140463
|
+
(0, typescript_1.fixConfig)(tsConfig, nodeVersionMajor);
|
140540
140464
|
// In prod, `.ts` inputs use TypeScript and
|
140541
140465
|
// `.js` inputs use Babel to convert ESM to CJS.
|
140542
140466
|
// In dev, both `.ts` and `.js` inputs use ts-node
|
@@ -140546,22 +140470,22 @@ const startDevServer = async (opts) => {
|
|
140546
140470
|
// In dev, we don't emit because we use ts-node.
|
140547
140471
|
tsConfig.compilerOptions.noEmit = true;
|
140548
140472
|
}
|
140549
|
-
const child = fork_dev_server_1.forkDevServer({
|
140473
|
+
const child = (0, fork_dev_server_1.forkDevServer)({
|
140550
140474
|
workPath,
|
140551
140475
|
config,
|
140552
140476
|
entrypoint,
|
140553
140477
|
require_,
|
140554
140478
|
isEsm,
|
140555
|
-
isTypeScript
|
140479
|
+
isTypeScript,
|
140556
140480
|
maybeTranspile,
|
140557
140481
|
meta,
|
140558
140482
|
tsConfig,
|
140559
140483
|
});
|
140560
140484
|
const { pid } = child;
|
140561
|
-
const message = await fork_dev_server_1.readMessage(child);
|
140485
|
+
const message = await (0, fork_dev_server_1.readMessage)(child);
|
140562
140486
|
if (message.state === 'message') {
|
140563
140487
|
// "message" event
|
140564
|
-
if (
|
140488
|
+
if (isTypeScript) {
|
140565
140489
|
// Invoke `tsc --noEmit` asynchronously in the background, so
|
140566
140490
|
// that the HTTP request is not blocked by the type checking.
|
140567
140491
|
doTypeCheck(opts, pathToTsConfig).catch((err) => {
|
@@ -140579,35 +140503,33 @@ const startDevServer = async (opts) => {
|
|
140579
140503
|
};
|
140580
140504
|
exports.startDevServer = startDevServer;
|
140581
140505
|
async function doTypeCheck({ entrypoint, workPath, meta = {} }, projectTsConfig) {
|
140582
|
-
const { devCacheDir = path_1.join(workPath, '.vercel', 'cache') } = meta;
|
140583
|
-
const entrypointCacheDir = path_1.join(devCacheDir, 'node', entrypoint);
|
140506
|
+
const { devCacheDir = (0, path_1.join)(workPath, '.vercel', 'cache') } = meta;
|
140507
|
+
const entrypointCacheDir = (0, path_1.join)(devCacheDir, 'node', entrypoint);
|
140584
140508
|
// In order to type-check a single file, a standalone tsconfig
|
140585
140509
|
// file needs to be created that inherits from the base one :(
|
140586
140510
|
// See: https://stackoverflow.com/a/44748041/376773
|
140587
140511
|
//
|
140588
140512
|
// A different filename needs to be used for different `extends` tsconfig.json
|
140589
140513
|
const tsconfigName = projectTsConfig
|
140590
|
-
? `tsconfig-with-${path_1.relative(workPath, projectTsConfig).replace(/[\\/.]/g, '-')}.json`
|
140514
|
+
? `tsconfig-with-${(0, path_1.relative)(workPath, projectTsConfig).replace(/[\\/.]/g, '-')}.json`
|
140591
140515
|
: 'tsconfig.json';
|
140592
|
-
const tsconfigPath = path_1.join(entrypointCacheDir, tsconfigName);
|
140516
|
+
const tsconfigPath = (0, path_1.join)(entrypointCacheDir, tsconfigName);
|
140593
140517
|
const tsconfig = {
|
140594
140518
|
extends: projectTsConfig
|
140595
|
-
? path_1.relative(entrypointCacheDir, projectTsConfig)
|
140519
|
+
? (0, path_1.relative)(entrypointCacheDir, projectTsConfig)
|
140596
140520
|
: undefined,
|
140597
|
-
include: [path_1.relative(entrypointCacheDir, path_1.join(workPath, entrypoint))],
|
140521
|
+
include: [(0, path_1.relative)(entrypointCacheDir, (0, path_1.join)(workPath, entrypoint))],
|
140598
140522
|
};
|
140599
140523
|
try {
|
140600
140524
|
const json = JSON.stringify(tsconfig, null, '\t');
|
140601
140525
|
await fs_1.promises.mkdir(entrypointCacheDir, { recursive: true });
|
140602
140526
|
await fs_1.promises.writeFile(tsconfigPath, json, { flag: 'wx' });
|
140603
140527
|
}
|
140604
|
-
catch (
|
140605
|
-
|
140606
|
-
|
140607
|
-
throw err;
|
140608
|
-
}
|
140528
|
+
catch (error) {
|
140529
|
+
if ((0, error_utils_1.isErrnoException)(error) && error.code !== 'EEXIST')
|
140530
|
+
throw error;
|
140609
140531
|
}
|
140610
|
-
const child = child_process_1.spawn(process.execPath, [
|
140532
|
+
const child = (0, child_process_1.spawn)(process.execPath, [
|
140611
140533
|
tscPath,
|
140612
140534
|
'--project',
|
140613
140535
|
tsconfigPath,
|
@@ -140869,7 +140791,7 @@ function register(opts = {}) {
|
|
140869
140791
|
const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
|
140870
140792
|
reportTSError(diagnosticList, config.options.noEmitOnError);
|
140871
140793
|
if (output.emitSkipped) {
|
140872
|
-
throw new TypeError(`${path_1.relative(cwd, fileName)}: Emit skipped`);
|
140794
|
+
throw new TypeError(`${(0, path_1.relative)(cwd, fileName)}: Emit skipped`);
|
140873
140795
|
}
|
140874
140796
|
// Throw an error when requiring `.d.ts` files.
|
140875
140797
|
if (output.outputFiles.length === 0) {
|
@@ -140877,7 +140799,7 @@ function register(opts = {}) {
|
|
140877
140799
|
'This is usually the result of a faulty configuration or import. ' +
|
140878
140800
|
'Make sure there is a `.js`, `.json` or another executable extension and ' +
|
140879
140801
|
'loader (attached before `ts-node`) available alongside ' +
|
140880
|
-
`\`${path_1.basename(fileName)}\`.`);
|
140802
|
+
`\`${(0, path_1.basename)(fileName)}\`.`);
|
140881
140803
|
}
|
140882
140804
|
const file = {
|
140883
140805
|
code: output.outputFiles[1].text,
|
@@ -140905,7 +140827,7 @@ function register(opts = {}) {
|
|
140905
140827
|
*/
|
140906
140828
|
function readConfig(configFileName) {
|
140907
140829
|
let config = { compilerOptions: {} };
|
140908
|
-
const basePath = normalizeSlashes(path_1.dirname(configFileName));
|
140830
|
+
const basePath = normalizeSlashes((0, path_1.dirname)(configFileName));
|
140909
140831
|
// Read project configuration when available.
|
140910
140832
|
if (configFileName) {
|
140911
140833
|
const result = ts.readConfigFile(configFileName, readFile);
|
@@ -140947,7 +140869,7 @@ function register(opts = {}) {
|
|
140947
140869
|
const output = {
|
140948
140870
|
code: value,
|
140949
140871
|
map: Object.assign(JSON.parse(sourceMap), {
|
140950
|
-
file: path_1.basename(fileName),
|
140872
|
+
file: (0, path_1.basename)(fileName),
|
140951
140873
|
sources: [fileName],
|
140952
140874
|
}),
|
140953
140875
|
};
|
@@ -141016,10 +140938,10 @@ function filterDiagnostics(diagnostics, ignore) {
|
|
141016
140938
|
"use strict";
|
141017
140939
|
|
141018
140940
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
141019
|
-
exports.isEdgeRuntime = exports.EdgeRuntimes = exports.logError = exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
|
141020
|
-
const path_1 = __webpack_require__(85622);
|
141021
|
-
const path_to_regexp_1 = __webpack_require__(91344);
|
140941
|
+
exports.serializeBody = exports.isEdgeRuntime = exports.EdgeRuntimes = exports.logError = exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
|
141022
140942
|
const build_utils_1 = __webpack_require__(63445);
|
140943
|
+
const path_to_regexp_1 = __webpack_require__(91344);
|
140944
|
+
const path_1 = __webpack_require__(85622);
|
141023
140945
|
function getRegExpFromMatchers(matcherOrMatchers) {
|
141024
140946
|
if (!matcherOrMatchers) {
|
141025
140947
|
return '^/.*$';
|
@@ -141038,9 +140960,9 @@ function getRegExpFromMatcher(matcher, index, allMatchers) {
|
|
141038
140960
|
if (!matcher.startsWith('/')) {
|
141039
140961
|
throw new Error(`Middleware's \`config.matcher\` values must start with "/". Received: ${matcher}`);
|
141040
140962
|
}
|
141041
|
-
const regExps = [path_to_regexp_1.pathToRegexp(matcher).source];
|
140963
|
+
const regExps = [(0, path_to_regexp_1.pathToRegexp)(matcher).source];
|
141042
140964
|
if (matcher === '/' && !allMatchers.includes('/index')) {
|
141043
|
-
regExps.push(path_to_regexp_1.pathToRegexp('/index').source);
|
140965
|
+
regExps.push((0, path_to_regexp_1.pathToRegexp)('/index').source);
|
141044
140966
|
}
|
141045
140967
|
return regExps;
|
141046
140968
|
}
|
@@ -141055,7 +140977,7 @@ function getRegExpFromMatcher(matcher, index, allMatchers) {
|
|
141055
140977
|
*/
|
141056
140978
|
function entrypointToOutputPath(entrypoint, zeroConfig) {
|
141057
140979
|
if (zeroConfig) {
|
141058
|
-
const ext = path_1.extname(entrypoint);
|
140980
|
+
const ext = (0, path_1.extname)(entrypoint);
|
141059
140981
|
return entrypoint.slice(0, entrypoint.length - ext.length);
|
141060
140982
|
}
|
141061
140983
|
return entrypoint;
|
@@ -141068,7 +140990,7 @@ function logError(error) {
|
|
141068
140990
|
// because it points to internals, not user code
|
141069
140991
|
const errorPrefixLength = 'Error: '.length;
|
141070
140992
|
const errorMessageLength = errorPrefixLength + error.message.length;
|
141071
|
-
build_utils_1.debug(error.stack.substring(errorMessageLength + 1));
|
140993
|
+
(0, build_utils_1.debug)(error.stack.substring(errorMessageLength + 1));
|
141072
140994
|
}
|
141073
140995
|
}
|
141074
140996
|
exports.logError = logError;
|
@@ -141082,6 +141004,12 @@ function isEdgeRuntime(runtime) {
|
|
141082
141004
|
Object.values(EdgeRuntimes).includes(runtime));
|
141083
141005
|
}
|
141084
141006
|
exports.isEdgeRuntime = isEdgeRuntime;
|
141007
|
+
async function serializeBody(request) {
|
141008
|
+
return request.method !== 'GET' && request.method !== 'HEAD'
|
141009
|
+
? await (0, build_utils_1.streamToBuffer)(request)
|
141010
|
+
: undefined;
|
141011
|
+
}
|
141012
|
+
exports.serializeBody = serializeBody;
|
141085
141013
|
|
141086
141014
|
|
141087
141015
|
/***/ }),
|
@@ -141157,6 +141085,14 @@ module.exports = require("@vercel/build-utils");
|
|
141157
141085
|
|
141158
141086
|
/***/ }),
|
141159
141087
|
|
141088
|
+
/***/ 27915:
|
141089
|
+
/***/ ((module) => {
|
141090
|
+
|
141091
|
+
"use strict";
|
141092
|
+
module.exports = require("@vercel/error-utils");
|
141093
|
+
|
141094
|
+
/***/ }),
|
141095
|
+
|
141160
141096
|
/***/ 27167:
|
141161
141097
|
/***/ ((module) => {
|
141162
141098
|
|