Compare commits

...

30 Commits

Author SHA1 Message Date
Chris Barber
2a441159f3 Move tsc options to tsconfig 2023-09-05 17:23:42 -05:00
Chris Barber
ddc5c2dbb6 Merge branch 'esbuild' into esbuild-go 2023-09-05 17:20:51 -05:00
Nathan Rajlich
55d574cd26 Merge branch 'main' of github.com:vercel/vercel into esbuild 2023-09-05 14:39:13 -07:00
Nathan Rajlich
18cdcf35d3 Move "emitDeclarationOnly" to tsconfig.json 2023-09-05 14:38:55 -07:00
Nathan Rajlich
d2ce05ba27 Lint 2023-09-05 14:19:54 -07:00
Nathan Rajlich
3f5f368b19 Parse tsconfig and pass relevant valuse to esbuild 2023-09-05 14:16:32 -07:00
Chris Barber
8d78cd22b2 Merge branch 'esbuild' into esbuild-go 2023-09-01 11:43:12 -07:00
Nathan Rajlich
10c3251b95 Merge branch 'main' into esbuild 2023-09-01 10:07:07 -07:00
Nathan Rajlich
bdd8958895 Merge branch 'main' into esbuild 2023-09-01 00:00:27 -07:00
Chris Barber
dd2a799535 Add --bundle 2023-08-31 15:41:37 -07:00
Chris Barber
047e245b45 Merge branch 'esbuild' into esbuild-go 2023-08-31 15:15:32 -07:00
Nathan Rajlich
52e0c01cf5 . 2023-08-31 15:12:21 -07:00
Chris Barber
46a8296e18 Merge branch 'esbuild' into esbuild-go 2023-08-31 15:04:21 -07:00
Nathan Rajlich
65ecb16b04 Fix Windows? 2023-08-31 15:01:33 -07:00
Chris Barber
8647400505 Merge branch 'esbuild' into esbuild-go 2023-08-31 14:59:39 -07:00
Nathan Rajlich
6ce38c4cc8 . 2023-08-31 14:41:01 -07:00
Nathan Rajlich
a27cfd661b Debug Windows 2023-08-31 14:40:18 -07:00
Chris Barber
a48d10cf35 Fixed build:js script name 2023-08-31 14:22:40 -07:00
Chris Barber
37ea6e3f88 Add outdir 2023-08-31 14:18:39 -07:00
Chris Barber
b7e0e2439e [go] Use new build 2023-08-31 14:17:20 -07:00
Nathan Rajlich
6523ab43b2 . 2023-08-31 14:14:22 -07:00
Nathan Rajlich
102a83f1b5 Merge branch 'main' of github.com:vercel/vercel into esbuild 2023-08-31 13:58:25 -07:00
Nathan Rajlich
93c5a2b182 . 2023-08-31 13:58:07 -07:00
Nathan Rajlich
323a8d7122 . 2023-08-31 13:49:08 -07:00
Nathan Rajlich
4ab1720df2 Convert a few more 2023-08-31 13:43:22 -07:00
Chris Barber
5c81fe0af4 [hydrogen] Use new build 2023-08-31 13:41:55 -07:00
Chris Barber
6495dd150e [frameworks] Use new build 2023-08-31 13:37:54 -07:00
Nathan Rajlich
1d69870141 Add changeset 2023-08-31 13:28:52 -07:00
Nathan Rajlich
2eee17de24 Use npm-run-all 2023-08-31 13:28:37 -07:00
Nathan Rajlich
e62b3da5a7 Add common esbuild script and enable for @vercel/error-utils 2023-08-31 13:19:41 -07:00
35 changed files with 441 additions and 389 deletions

View File

@@ -0,0 +1,2 @@
---
---

View File

@@ -8,7 +8,9 @@
"dist"
],
"scripts": {
"build": "tsc",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test tests/unit"
},

View File

@@ -1,7 +1,9 @@
{
"extends": "@vercel-internals/tsconfig",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["src/**/*"]
}

View File

@@ -16,6 +16,7 @@
"buffer-replace": "1.0.0",
"create-svelte": "2.0.1",
"dot": "1.1.3",
"esbuild": "0.19.2",
"eslint": "8.14.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "26.1.5",
@@ -28,6 +29,7 @@
"lint-staged": "9.2.5",
"node-fetch": "2.6.7",
"npm-package-arg": "6.1.0",
"npm-run-all": "4.1.5",
"prettier": "2.6.2",
"source-map-support": "0.5.12",
"ts-eager": "2.0.2",

View File

@@ -1,30 +0,0 @@
#!/usr/bin/env node
const fs = require('fs-extra');
const execa = require('execa');
const { join } = require('path');
async function main() {
const outDir = join(__dirname, 'dist');
// Start fresh
await fs.remove(outDir);
// Compile TypeScript
await execa('tsc', [], { stdio: 'inherit' });
// Run `ncc`
const mainDir = join(outDir, 'main');
await execa('ncc', ['build', 'src/index.ts', '-o', mainDir], {
stdio: 'inherit',
});
// Move compiled ncc file to out dir
await fs.rename(join(mainDir, 'index.js'), join(outDir, 'index.js'));
// Delete leftover "main" dir
await fs.remove(mainDir);
}
main().catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -11,7 +11,11 @@
"directory": "packages/now-build-utils"
},
"scripts": {
"build": "node build",
"build": "run-p build:js build:types",
"build:js": "run-s build:single build:bundle",
"build:single": "node ../../scripts/esbuild.mjs",
"build:bundle": "node ../../scripts/esbuild.mjs --bundle",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test test/unit.*test.*",
"test-e2e": "pnpm test test/integration.test.ts"

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -14,7 +14,9 @@
"directory": "packages/client"
},
"scripts": {
"build": "tsc",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test-e2e": "pnpm test tests/create-deployment.test.ts tests/create-legacy-deployment.test.ts tests/paths.test.ts",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test tests/unit.*test.*"

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -13,7 +13,9 @@
"directory": "packages/error-utils"
},
"scripts": {
"build": "tsc",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --coverage --env node --verbose",
"test-unit": "pnpm test"
},

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -13,7 +13,9 @@
},
"license": "Apache-2.0",
"scripts": {
"build": "tsc",
"build": "run-p build:*",
"build:src": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test"
},

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -14,7 +14,9 @@
},
"license": "Apache-2.0",
"scripts": {
"build": "tsc",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test test/unit.*test.*",
"test-e2e": "pnpm test test/integration.test.ts"

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env node
const fs = require('fs-extra');
const execa = require('execa');
const { join } = require('path');
async function main() {
const outDir = join(__dirname, 'dist');
// Start fresh
await fs.remove(outDir);
// Build with `ncc`
await execa(
'ncc',
['build', 'index.ts', '-e', '@vercel/build-utils', '-o', outDir],
{
stdio: 'inherit',
}
);
}
main().catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -10,32 +10,35 @@
"directory": "packages/go"
},
"scripts": {
"build": "node build",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs --bundle",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-e2e": "pnpm test"
},
"files": [
"dist"
"dist",
"*.go"
],
"devDependencies": {
"@tootallnate/once": "1.1.2",
"@types/async-retry": "1.4.2",
"@types/async-retry": "1.4.5",
"@types/execa": "^0.9.0",
"@types/fs-extra": "^5.0.5",
"@types/jest": "28.1.6",
"@types/node": "14.18.33",
"@types/node-fetch": "^2.3.0",
"@types/tar": "^4.0.0",
"@types/tar": "^6.1.5",
"@types/yauzl-promise": "2.1.0",
"@vercel/build-utils": "7.1.0",
"@vercel/ncc": "0.24.0",
"async-retry": "1.3.1",
"async-retry": "1.3.3",
"execa": "^1.0.0",
"fs-extra": "^7.0.0",
"jest-junit": "16.0.0",
"node-fetch": "^2.2.1",
"string-argv": "0.3.1",
"tar": "4.4.6",
"tar": "6.1.15",
"typescript": "4.3.4",
"xdg-app-paths": "5.1.0",
"yauzl-promise": "2.1.3"

View File

@@ -108,7 +108,7 @@ export async function getAnalyzedEntrypoint({
const isAnalyzeExist = await pathExists(bin);
if (!isAnalyzeExist) {
debug(`Building analyze bin: ${bin}`);
const src = join(__dirname, 'util', 'analyze.go');
const src = join(__dirname, '../analyze.go');
let go;
const createOpts = {
modulePath,

View File

@@ -621,7 +621,7 @@ async function copyDevServer(
functionName: string,
dest: string
): Promise<void> {
const data = await readFile(join(__dirname, 'dev-server.go'), 'utf8');
const data = await readFile(join(__dirname, '../dev-server.go'), 'utf8');
// Populate the handler function name
const patched = data.replace('__HANDLER_FUNC_NAME', functionName);
@@ -634,7 +634,10 @@ async function writeEntrypoint(
goPackageName: string,
goFuncName: string
) {
const modMainGoContents = await readFile(join(__dirname, 'main.go'), 'utf8');
const modMainGoContents = await readFile(
join(__dirname, '../main.go'),
'utf8'
);
const mainModGoContents = modMainGoContents
.replace('__VC_HANDLER_PACKAGE_NAME', goPackageName)
.replace('__VC_HANDLER_FUNC_NAME', goFuncName);

View File

@@ -1,4 +1,4 @@
import { getNewHandlerFunctionName } from '../index';
import { getNewHandlerFunctionName } from '../src/index';
describe('getNewHandlerFunctionName', function () {
it('does nothing with empty original function name', async () => {

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": false,
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",
@@ -11,6 +12,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitThis": false,
"outDir": "dist",
"types": ["node", "jest"],
"strict": true,
"target": "ES2021"

View File

@@ -1,12 +0,0 @@
const execa = require('execa');
const { remove } = require('fs-extra');
async function main() {
await remove('dist');
await execa('tsc', [], { stdio: 'inherit' });
}
main().catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -10,7 +10,9 @@
"directory": "packages/hydrogen"
},
"scripts": {
"build": "node build.js",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test-e2e": "pnpm test test/test.js",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail --runInBand"
},

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -1,12 +0,0 @@
const execa = require('execa');
const { remove } = require('fs-extra');
async function main() {
await remove('dist');
await execa('tsc', [], { stdio: 'inherit' });
}
main().catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -10,7 +10,9 @@
"directory": "packages/remix"
},
"scripts": {
"build": "node build.js",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail --runInBand",
"test-unit": "pnpm test test/unit.*test.*",
"test-e2e": "pnpm test test/integration.test.ts"

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",

View File

@@ -14,7 +14,9 @@
},
"license": "Apache-2.0",
"scripts": {
"build": "tsc",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test"
},

View File

@@ -8,6 +8,7 @@
"outDir": "dist",
"sourceMap": false,
"declaration": true,
"emitDeclarationOnly": true,
"typeRoots": ["./@types", "./node_modules/@types"]
},
"include": ["src/**/*"],

View File

@@ -9,7 +9,9 @@
"directory": "packages/static-config"
},
"scripts": {
"build": "tsc",
"build": "run-p build:*",
"build:js": "node ../../scripts/esbuild.mjs",
"build:types": "tsc",
"test-unit": "pnpm test",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail"
},

View File

@@ -8,6 +8,7 @@
"outDir": "dist",
"sourceMap": true,
"declaration": true,
"emitDeclarationOnly": true,
"moduleResolution": "node",
"typeRoots": ["./@types", "./node_modules/@types"]
},

609
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

45
scripts/esbuild.mjs Normal file
View File

@@ -0,0 +1,45 @@
import ts from 'typescript';
import * as path from 'path';
import { build } from 'esbuild';
function parseTsConfig(tsconfigPath) {
const parsedConfig = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
if (parsedConfig.error) {
console.error(
'Error parsing tsconfig:',
ts.flattenDiagnosticMessageText(parsedConfig.error.messageText, '\n')
);
return;
}
const result = ts.parseJsonConfigFileContent(
parsedConfig.config,
ts.sys,
path.dirname(tsconfigPath)
);
if (result.errors && result.errors.length > 0) {
for (const error of result.errors) {
console.error(ts.flattenDiagnosticMessageText(error.messageText, '\n'));
}
return;
}
return result;
}
const cwd = process.cwd();
const configPath = path.join(cwd, 'tsconfig.json');
const tsconfig = parseTsConfig(configPath);
if (!tsconfig) {
process.exit(1);
}
await build({
entryPoints: tsconfig.fileNames,
bundle: process.argv.includes('--bundle'),
format: 'cjs',
outdir: tsconfig.options.outDir,
platform: 'node',
target: ts.ScriptTarget[tsconfig.options.target],
sourcemap: tsconfig.options.sourceMap,
});

View File

@@ -1,6 +1,11 @@
{
"$schema": "https://turborepo.org/schema.json",
"globalDependencies": ["turbo-cache-key.json", "package.json", "test/lib/**"],
"globalDependencies": [
"turbo-cache-key.json",
"package.json",
"test/lib/**",
"scripts/esbuild.mjs"
],
"pipeline": {
"build": {
"dependsOn": ["^build"],