mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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",
|
"fork-ts-checker-webpack-plugin": "8.0.0",
|
||||||
"glob": "10.3.3",
|
"glob": "10.3.3",
|
||||||
"replace-in-file-webpack-plugin": "1.0.6",
|
"replace-in-file-webpack-plugin": "1.0.6",
|
||||||
|
"swc-loader": "0.2.3",
|
||||||
"webpack": "5.89.0"
|
"webpack": "5.89.0"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@3.6.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 ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
|
import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
|
||||||
import { Configuration } from 'webpack';
|
import { Configuration, DefinePlugin } from 'webpack';
|
||||||
|
|
||||||
import { DIST_DIR } from './constants';
|
import { DIST_DIR } from './constants';
|
||||||
import { getPackageJson, getPluginJson, getEntries, hasLicense } from './utils';
|
import { getPackageJson, getPluginJson, getEntries, hasLicense } from './utils';
|
||||||
@ -29,12 +29,6 @@ const config = async (env: Record<string, unknown>): Promise<Configuration> => {
|
|||||||
config: [__filename],
|
config: [__filename],
|
||||||
},
|
},
|
||||||
cacheDirectory: path.resolve(__dirname, '../../.yarn/.cache/webpack', path.basename(process.cwd())),
|
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(),
|
context: process.cwd(),
|
||||||
@ -89,7 +83,7 @@ const config = async (env: Record<string, unknown>): Promise<Configuration> => {
|
|||||||
exclude: /(node_modules)/,
|
exclude: /(node_modules)/,
|
||||||
test: /\.[tj]sx?$/,
|
test: /\.[tj]sx?$/,
|
||||||
use: {
|
use: {
|
||||||
loader: 'swc-loader',
|
loader: require.resolve('swc-loader'),
|
||||||
options: {
|
options: {
|
||||||
jsc: {
|
jsc: {
|
||||||
baseUrl: '.',
|
baseUrl: '.',
|
||||||
@ -186,21 +180,31 @@ const config = async (env: Record<string, unknown>): Promise<Configuration> => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
new ForkTsCheckerWebpackPlugin({
|
env.development
|
||||||
async: Boolean(env.development),
|
? new ForkTsCheckerWebpackPlugin({
|
||||||
issue: {
|
async: true,
|
||||||
include: [{ file: '**/*.{ts,tsx}' }],
|
issue: {
|
||||||
},
|
include: [{ file: '**/*.{ts,tsx}' }],
|
||||||
typescript: { configFile: path.join(process.cwd(), 'tsconfig.json') },
|
},
|
||||||
}),
|
typescript: { configFile: path.join(process.cwd(), 'tsconfig.json') },
|
||||||
new ESLintPlugin({
|
})
|
||||||
extensions: ['.ts', '.tsx'],
|
: new DefinePlugin({}),
|
||||||
lintDirtyModulesOnly: Boolean(env.development), // don't lint on start, only lint changed files
|
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: {
|
resolve: {
|
||||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
||||||
unsafeCache: true,
|
unsafeCache: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
"@types/node": "18.18.5",
|
"@types/node": "18.18.5",
|
||||||
"@types/react": "18.2.15",
|
"@types/react": "18.2.15",
|
||||||
"@types/testing-library__jest-dom": "5.14.8",
|
"@types/testing-library__jest-dom": "5.14.8",
|
||||||
"swc-loader": "0.2.3",
|
|
||||||
"ts-node": "10.9.1",
|
"ts-node": "10.9.1",
|
||||||
"webpack": "5.89.0"
|
"webpack": "5.89.0"
|
||||||
},
|
},
|
||||||
|
@ -2857,7 +2857,6 @@ __metadata:
|
|||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
react-use: 17.4.0
|
react-use: 17.4.0
|
||||||
rxjs: 7.8.1
|
rxjs: 7.8.1
|
||||||
swc-loader: 0.2.3
|
|
||||||
ts-node: 10.9.1
|
ts-node: 10.9.1
|
||||||
tslib: 2.6.0
|
tslib: 2.6.0
|
||||||
webpack: 5.89.0
|
webpack: 5.89.0
|
||||||
@ -3255,6 +3254,7 @@ __metadata:
|
|||||||
fork-ts-checker-webpack-plugin: 8.0.0
|
fork-ts-checker-webpack-plugin: 8.0.0
|
||||||
glob: 10.3.3
|
glob: 10.3.3
|
||||||
replace-in-file-webpack-plugin: 1.0.6
|
replace-in-file-webpack-plugin: 1.0.6
|
||||||
|
swc-loader: 0.2.3
|
||||||
tslib: 2.6.0
|
tslib: 2.6.0
|
||||||
webpack: 5.89.0
|
webpack: 5.89.0
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
|
Loading…
Reference in New Issue
Block a user