Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(website): update build script to use esbuild instead of rollup#6716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
armano2 merged 12 commits intov6fromchore/website-eslint-improve-build
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
12 commits
Select commitHold shift + click to select a range
01b9f00
chore(website-eslint): update build script to use esbuild instead of …
armano2Mar 21, 2023
ae2b1b1
Merge remote-tracking branch 'origin/v6' into chore/website-eslint-im…
armano2Mar 21, 2023
539e391
fix: correct linting issues
armano2Mar 21, 2023
730a92c
Merge remote-tracking branch 'origin/v6' into chore/website-eslint-im…
armano2Mar 24, 2023
3a68591
chore: build bundle from source code and remove unnecessary use-at-yo…
armano2Mar 24, 2023
f6fb77f
fix: correct displaying errors and warning
armano2Mar 24, 2023
22b855b
fix: build code as iife to not pollute global scope
armano2Mar 25, 2023
f1799d9
fix: use banner & footer as amd wrapper
armano2Mar 25, 2023
58d543d
fix: add missing support for aliases
armano2Mar 25, 2023
cf761c6
Merge branch 'v6' into chore/website-eslint-improve-build
armano2Mar 29, 2023
8c9a0cd
chore: restore missing comment
armano2Mar 29, 2023
2d992dc
chore: remove rollup from renovate
armano2Mar 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions.github/renovate.json5
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,16 +16,6 @@
'@nrwl/jest',
'@nrwl/nx-cloud',
'@nrwl/tao',
// TODO - once we bump pass the major, we can remove these. Currently renovate is creating broken, immortal PRs
'@rollup/plugin-babel',
'@rollup/plugin-commonjs',
'@rollup/plugin-json',
'@rollup/plugin-node-resolve',
'@rollup/plugin-replace',
'@rollup/plugin-terser',
'@rollup/pluginutils',
'rollup-plugin-terser',
'rollup',
],
ignorePaths: [
// integration test package.json's should never be updated as they're purposely fixed tests
Expand DownExpand Up@@ -85,11 +75,6 @@
matchPackagePrefixes: ['@types/jest', 'jest-', '@jest/'],
groupName: 'jest',
},
{
matchPackagePrefixes: ['@rollup', 'rollup-'],
matchPackageNames: ['rollup'],
groupName: 'rollup',
},
],
postUpdateOptions: [
// run yarn dedupe to cleanup the lockfile after updates
Expand Down
6 changes: 1 addition & 5 deletionspackages/scope-manager/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,11 +14,7 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./package.json": "./package.json",
"./use-at-your-own-risk/analyze": {
"types": "./dist/analyze.d.ts",
"default": "./dist/analyze.js"
}
"./package.json": "./package.json"
},
"engines": {
"node": "^14.18.0 || ^16.0.0 || >=18.0.0"
Expand Down
14 changes: 3 additions & 11 deletionspackages/typescript-estree/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,17 +15,9 @@
"default": "./dist/index.js"
},
"./package.json": "./package.json",
"./use-at-your-own-risk/ast-converter": {
"types": "./dist/ast-converter.d.ts",
"default": "./dist/ast-converter.js"
},
"./use-at-your-own-risk/parseSettings": {
"types": "./dist/parseSettings/index.d.ts",
"default": "./dist/parseSettings/index.js"
},
"./use-at-your-own-risk/getScriptKind": {
"types": "./dist/create-program/getScriptKind.d.ts",
"default": "./dist/create-program/getScriptKind.js"
"./use-at-your-own-risk": {
"types": "./dist/use-at-your-own-risk.d.ts",
"default": "./dist/use-at-your-own-risk.js"
}
},
"engines": {
Expand Down
8 changes: 8 additions & 0 deletionspackages/typescript-estree/src/use-at-your-own-risk.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
// required by website
export * from './create-program/getScriptKind';
export * from './ast-converter';
export type { ParseSettings } from './parseSettings';

// required by packages/utils/src/ts-estree.ts
export * from './getModifiers';
export { typescriptVersionIsAtLeast } from './version-check';
6 changes: 1 addition & 5 deletionspackages/visitor-keys/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,11 +15,7 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./package.json": "./package.json",
"./use-at-your-own-risk/visitor-keys": {
"types": "./dist/visitor-keys.d.ts",
"default": "./dist/visitor-keys.js"
}
"./package.json": "./package.json"
},
"engines": {
"node": "^14.18.0 || ^16.0.0 || >=18.0.0"
Expand Down
167 changes: 167 additions & 0 deletionspackages/website-eslint/build.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
/* eslint-disable no-process-exit, no-console */

import * as fs from 'node:fs/promises';
import { createRequire } from 'node:module';
import * as path from 'node:path';

import * as esbuild from 'esbuild';

function requireResolved(targetPath: string): string {
return createRequire(__filename).resolve(targetPath);
}

function normalizePath(filePath: string): string {
return filePath.replace(/\\/g, '/');
}

function requireMock(targetPath: string): Promise<string> {
return fs.readFile(requireResolved(targetPath), 'utf8');
}

function makeFilter(filePath: string | string[]): { filter: RegExp } {
const paths = Array.isArray(filePath) ? filePath : [filePath];
const norm = paths.map(item =>
normalizePath(item).replace(/\//g, '[\\\\/]').replace(/\./g, '\\.'),
);
return { filter: new RegExp('(' + norm.join('|') + ')$') };
}

function createResolve(
targetPath: string,
join: string,
): esbuild.OnResolveResult {
const resolvedPackage = requireResolved(targetPath + '/package.json');
return {
path: path.join(resolvedPackage, '../src/', join),
};
}

async function buildPackage(name: string, file: string): Promise<void> {
const eslintRoot = requireResolved('eslint/package.json');
const linterPath = path.join(eslintRoot, '../lib/linter/linter.js');
const rulesPath = path.join(eslintRoot, '../lib/rules/index.js');

await esbuild.build({
entryPoints: {
[name]: requireResolved(file),
},
format: 'cjs',
platform: 'browser',
bundle: true,
external: [],
minify: true,
treeShaking: true,
write: true,
target: 'es2020',
sourcemap: 'linked',
outdir: './dist/',
supported: {},
banner: {
// https://github.com/evanw/esbuild/issues/819
js: `define(['exports', 'vs/language/typescript/tsWorker'], function (exports) {`,
},
footer: {
// https://github.com/evanw/esbuild/issues/819
js: `});`,
},
define: {
'process.env.NODE_ENV': '"production"',
'process.env.NODE_DEBUG': 'false',
'process.env.IGNORE_TEST_WIN32': 'true',
'process.env.DEBUG': 'false',
'process.emitWarning': 'console.warn',
'process.platform': '"browser"',
'process.env.TIMING': 'undefined',
'define.amd': 'false',
global: 'window',
},
alias: {
util: requireResolved('./src/mock/util.js'),
assert: requireResolved('./src/mock/assert.js'),
path: requireResolved('./src/mock/path.js'),
typescript: requireResolved('./src/mock/typescript.js'),
'lru-cache': requireResolved('./src/mock/lru-cache.js'),
},
plugins: [
{
name: 'replace-plugin',
setup(build): void {
build.onLoad(
makeFilter([
'/eslint-utils/rule-tester/RuleTester.ts',
'/ts-eslint/ESLint.ts',
'/ts-eslint/RuleTester.ts',
'/ts-eslint/CLIEngine.ts',
]),
async args => {
console.log('onLoad:replace', args.path);
const contents = await requireMock('./src/mock/empty.js');
return { contents, loader: 'js' };
},
);
build.onLoad(
makeFilter('/eslint/lib/unsupported-api.js'),
async args => {
console.log('onLoad:eslint:unsupported-api', args.path);
let contents = await requireMock('./src/mock/eslint-rules.js');
// this is needed to bypass system module resolver
contents = contents.replace(
'vt:eslint/rules',
normalizePath(rulesPath),
);
return { contents, loader: 'js' };
},
);
build.onLoad(makeFilter('/eslint/lib/api.js'), async args => {
console.log('onLoad:eslint', args.path);
let text = await requireMock('./src/mock/eslint.js');
// this is needed to bypass system module resolver
text = text.replace('vt:eslint/linter', normalizePath(linterPath));
return { contents: text, loader: 'js' };
});
build.onResolve(
makeFilter([
'@typescript-eslint/typescript-estree',
'@typescript-eslint/typescript-estree/use-at-your-own-risk',
]),
() =>
createResolve(
'@typescript-eslint/typescript-estree',
'use-at-your-own-risk.ts',
),
);
const anyAlias = /^(@typescript-eslint\/[a-z-]+)\/([a-z-]+)$/;
build.onResolve({ filter: anyAlias }, args => {
const parts = args.path.match(anyAlias);
if (parts) {
return createResolve(parts[1], `${parts[2]}/index.ts`);
}
return null;
});
build.onResolve(makeFilter('@typescript-eslint/[a-z-]+'), args =>
createResolve(args.path, 'index.ts'),
);
build.onEnd(e => {
for (const error of e.errors) {
console.error(error);
}
for (const warning of e.warnings) {
console.warn(warning);
}
});
},
},
],
});
}

console.time('building eslint for web');

buildPackage('index', './src/index.js')
.then(() => {
console.timeEnd('building eslint for web');
})
.catch((e: unknown) => {
console.error(String(e));
process.exit(1);
});
16 changes: 4 additions & 12 deletionspackages/website-eslint/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,30 +17,22 @@
"node": "^14.18.0 || ^16.0.0 || >=18.0.0"
},
"scripts": {
"build": "rollup --config=rollup.config.js",
"build": "yarn tsx ./build.ts",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "nx lint",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@typescript-eslint/types": "5.56.0",
"@typescript-eslint/utils": "5.56.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^23.0.0",
"@rollup/plugin-json": "^5.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/pluginutils": "^5.0.0",
"@typescript-eslint/eslint-plugin": "5.56.0",
"@typescript-eslint/parser": "5.56.0",
"@typescript-eslint/scope-manager": "5.56.0",
"@typescript-eslint/typescript-estree": "5.56.0",
"@typescript-eslint/visitor-keys": "5.56.0",
"@typescript-eslint/types": "5.56.0",
"@typescript-eslint/utils": "5.56.0",
"eslint": "*",
"esbuild": "~0.17.12",
"esquery": "*",
"magic-string": "0.25.9",
"rollup": "^2.75.4",
"semver": "^7.3.7"
}
}
96 changes: 0 additions & 96 deletionspackages/website-eslint/rollup-plugin/replace.js
View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp