@vercel/node 2.1.0 → 2.1.1-canary.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/index.js +41 -19
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -306748,28 +306748,50 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
|
306748
306748
|
const traceTime = Date.now();
|
|
306749
306749
|
const { preparedFiles, shouldAddSourcemapSupport } = await compile(workPath, baseDir, entrypointPath, config, nodeVersion);
|
|
306750
306750
|
build_utils_1.debug(`Trace complete [${Date.now() - traceTime}ms]`);
|
|
306751
|
-
|
|
306752
|
-
const staticConfig = static_config_1.getConfig(project, entrypointPath);
|
|
306751
|
+
let routes;
|
|
306753
306752
|
let output;
|
|
306754
306753
|
const handler = renameTStoJS(path_1.relative(baseDir, entrypointPath));
|
|
306755
|
-
|
|
306756
|
-
|
|
306757
|
-
|
|
306758
|
-
|
|
306759
|
-
|
|
306760
|
-
|
|
306761
|
-
|
|
306762
|
-
|
|
306763
|
-
|
|
306764
|
-
|
|
306765
|
-
|
|
306766
|
-
|
|
306767
|
-
|
|
306768
|
-
|
|
306769
|
-
|
|
306754
|
+
const outputName = config.zeroConfig
|
|
306755
|
+
? handler.substring(0, handler.length - 3)
|
|
306756
|
+
: handler;
|
|
306757
|
+
// Will output an `EdgeFunction` for when `config.middleware = true`
|
|
306758
|
+
// (i.e. for root-level "middleware" file) or if source code contains:
|
|
306759
|
+
// `export const config = { runtime: 'experimental-edge' }`
|
|
306760
|
+
let isEdgeFunction = false;
|
|
306761
|
+
// Add a catch-all `route` for Middleware
|
|
306762
|
+
if (config.middleware === true) {
|
|
306763
|
+
routes = [
|
|
306764
|
+
{
|
|
306765
|
+
src: '/.*',
|
|
306766
|
+
middlewarePath: config.zeroConfig
|
|
306767
|
+
? outputName
|
|
306768
|
+
: path_1.relative(baseDir, entrypointPath),
|
|
306769
|
+
continue: true,
|
|
306770
|
+
},
|
|
306771
|
+
];
|
|
306772
|
+
// Middleware is implicitly an Edge Function
|
|
306773
|
+
isEdgeFunction = true;
|
|
306774
|
+
}
|
|
306775
|
+
if (!isEdgeFunction) {
|
|
306776
|
+
const project = new ts_morph_1.Project();
|
|
306777
|
+
const staticConfig = static_config_1.getConfig(project, entrypointPath);
|
|
306778
|
+
if (staticConfig?.runtime) {
|
|
306779
|
+
if (!ALLOWED_RUNTIMES.includes(staticConfig.runtime)) {
|
|
306780
|
+
throw new Error(`Unsupported "runtime" property in \`config\`: ${JSON.stringify(staticConfig.runtime)} (must be one of: ${JSON.stringify(ALLOWED_RUNTIMES)})`);
|
|
306781
|
+
}
|
|
306782
|
+
isEdgeFunction = staticConfig.runtime === 'experimental-edge';
|
|
306770
306783
|
}
|
|
306771
306784
|
}
|
|
306772
|
-
if (
|
|
306785
|
+
if (isEdgeFunction) {
|
|
306786
|
+
output = new build_utils_1.EdgeFunction({
|
|
306787
|
+
entrypoint: handler,
|
|
306788
|
+
files: preparedFiles,
|
|
306789
|
+
// TODO: remove - these two properties should not be required
|
|
306790
|
+
name: outputName,
|
|
306791
|
+
deploymentTarget: 'v8-worker',
|
|
306792
|
+
});
|
|
306793
|
+
}
|
|
306794
|
+
else {
|
|
306773
306795
|
// "nodejs" runtime is the default
|
|
306774
306796
|
const shouldAddHelpers = !(config.helpers === false || process.env.NODEJS_HELPERS === '0');
|
|
306775
306797
|
output = new build_utils_1.NodejsLambda({
|
|
@@ -306781,7 +306803,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
|
306781
306803
|
awsLambdaHandler,
|
|
306782
306804
|
});
|
|
306783
306805
|
}
|
|
306784
|
-
return { output };
|
|
306806
|
+
return { routes, output };
|
|
306785
306807
|
};
|
|
306786
306808
|
exports.build = build;
|
|
306787
306809
|
const prepareCache = ({ repoRootPath, workPath }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/node",
|
|
3
|
-
"version": "2.1.0",
|
|
3
|
+
"version": "2.1.1-canary.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/etag": "1.8.0",
|
|
46
46
|
"@types/jest": "27.4.1",
|
|
47
47
|
"@types/test-listen": "1.1.0",
|
|
48
|
-
"@vercel/build-utils": "4.1.0",
|
|
48
|
+
"@vercel/build-utils": "4.1.1-canary.0",
|
|
49
49
|
"@vercel/ncc": "0.24.0",
|
|
50
50
|
"@vercel/nft": "0.19.1",
|
|
51
51
|
"@vercel/static-config": "2.0.1",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"source-map-support": "0.5.12",
|
|
57
57
|
"test-listen": "1.1.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "4bf6295d7a1d6544f195d76a2a4aedb476fa7dc1"
|
|
60
60
|
}
|