mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 18:01:40 -06:00
Build: Faster external plugin builds (#76974)
* build(plugin-configs): move swc-loader to configs and use require.resolve for less duplicate deps * build(plugins): move cacheLocation to ESLintPlugin, run lint and tscheck plugins in dev * revert(plugins): remove obsolete stats setting
This commit is contained in:
parent
03a626f1d6
commit
afa697f954
@ -13,6 +13,7 @@
|
||||
"fork-ts-checker-webpack-plugin": "8.0.0",
|
||||
"glob": "10.3.3",
|
||||
"replace-in-file-webpack-plugin": "1.0.6",
|
||||
"swc-loader": "0.2.3",
|
||||
"webpack": "5.89.0"
|
||||
},
|
||||
"packageManager": "yarn@3.6.0"
|
||||
|
@ -3,7 +3,7 @@ import ESLintPlugin from 'eslint-webpack-plugin';
|
||||
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
||||
import path from 'path';
|
||||
import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
|
||||
import { Configuration } from 'webpack';
|
||||
import { Configuration, DefinePlugin } from 'webpack';
|
||||
|
||||
import { DIST_DIR } from './constants';
|
||||
import { getPackageJson, getPluginJson, getEntries, hasLicense } from './utils';
|
||||
@ -29,12 +29,6 @@ const config = async (env: Record<string, unknown>): Promise<Configuration> => {
|
||||
config: [__filename],
|
||||
},
|
||||
cacheDirectory: path.resolve(__dirname, '../../.yarn/.cache/webpack', path.basename(process.cwd())),
|
||||
cacheLocation: path.resolve(
|
||||
__dirname,
|
||||
'../../.yarn/.cache/eslint-webpack-plugin',
|
||||
path.basename(process.cwd()),
|
||||
'.eslintcache'
|
||||
),
|
||||
},
|
||||
|
||||
context: process.cwd(),
|
||||
@ -89,7 +83,7 @@ const config = async (env: Record<string, unknown>): Promise<Configuration> => {
|
||||
exclude: /(node_modules)/,
|
||||
test: /\.[tj]sx?$/,
|
||||
use: {
|
||||
loader: 'swc-loader',
|
||||
loader: require.resolve('swc-loader'),
|
||||
options: {
|
||||
jsc: {
|
||||
baseUrl: '.',
|
||||
@ -186,21 +180,31 @@ const config = async (env: Record<string, unknown>): Promise<Configuration> => {
|
||||
],
|
||||
},
|
||||
]),
|
||||
new ForkTsCheckerWebpackPlugin({
|
||||
async: Boolean(env.development),
|
||||
issue: {
|
||||
include: [{ file: '**/*.{ts,tsx}' }],
|
||||
},
|
||||
typescript: { configFile: path.join(process.cwd(), 'tsconfig.json') },
|
||||
}),
|
||||
new ESLintPlugin({
|
||||
extensions: ['.ts', '.tsx'],
|
||||
lintDirtyModulesOnly: Boolean(env.development), // don't lint on start, only lint changed files
|
||||
}),
|
||||
env.development
|
||||
? new ForkTsCheckerWebpackPlugin({
|
||||
async: true,
|
||||
issue: {
|
||||
include: [{ file: '**/*.{ts,tsx}' }],
|
||||
},
|
||||
typescript: { configFile: path.join(process.cwd(), 'tsconfig.json') },
|
||||
})
|
||||
: new DefinePlugin({}),
|
||||
env.development
|
||||
? new ESLintPlugin({
|
||||
extensions: ['.ts', '.tsx'],
|
||||
lintDirtyModulesOnly: true, // don't lint on start, only lint changed files
|
||||
cacheLocation: path.resolve(
|
||||
__dirname,
|
||||
'../../.yarn/.cache/eslint-webpack-plugin',
|
||||
path.basename(process.cwd()),
|
||||
'.eslintcache'
|
||||
),
|
||||
})
|
||||
: new DefinePlugin({}),
|
||||
],
|
||||
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
||||
unsafeCache: true,
|
||||
},
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
"@types/node": "18.18.5",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/testing-library__jest-dom": "5.14.8",
|
||||
"swc-loader": "0.2.3",
|
||||
"ts-node": "10.9.1",
|
||||
"webpack": "5.89.0"
|
||||
},
|
||||
|
@ -2857,7 +2857,6 @@ __metadata:
|
||||
react: 18.2.0
|
||||
react-use: 17.4.0
|
||||
rxjs: 7.8.1
|
||||
swc-loader: 0.2.3
|
||||
ts-node: 10.9.1
|
||||
tslib: 2.6.0
|
||||
webpack: 5.89.0
|
||||
@ -3255,6 +3254,7 @@ __metadata:
|
||||
fork-ts-checker-webpack-plugin: 8.0.0
|
||||
glob: 10.3.3
|
||||
replace-in-file-webpack-plugin: 1.0.6
|
||||
swc-loader: 0.2.3
|
||||
tslib: 2.6.0
|
||||
webpack: 5.89.0
|
||||
languageName: unknown
|
||||
|
Loading…
Reference in New Issue
Block a user