зеркало из https://github.com/microsoft/just.git
Adds loader options support to tsoverlay (#251)
* adding loaderoptions for tsoverlay * Change files * adding support for the LoaderOptions for tsoverlay * gotta love typescript
This commit is contained in:
Родитель
6193364e35
Коммит
9b93f584f3
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"type": "minor",
|
||||||
|
"comment": "adding loaderoptions for tsoverlay",
|
||||||
|
"packageName": "just-scripts",
|
||||||
|
"email": "odbuild@microsoft.com",
|
||||||
|
"commit": "bcb1f45b53956000e9fe03e6eff84c1f27d9375a",
|
||||||
|
"date": "2019-09-27T16:25:11.131Z"
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ export * from './webpack/webpack.config';
|
||||||
export * from './webpack/webpack.serve.config';
|
export * from './webpack/webpack.serve.config';
|
||||||
|
|
||||||
// Webpack configs and overlays
|
// Webpack configs and overlays
|
||||||
import { tsOverlay } from './webpack/overlays/tsOverlay';
|
import { tsOverlay, TsCheckerOptions, TsLoaderOptions } from './webpack/overlays/tsOverlay';
|
||||||
import { htmlOverlay } from './webpack/overlays/htmlOverlay';
|
import { htmlOverlay } from './webpack/overlays/htmlOverlay';
|
||||||
import { stylesOverlay, createStylesOverlay } from './webpack/overlays/stylesOverlay';
|
import { stylesOverlay, createStylesOverlay } from './webpack/overlays/stylesOverlay';
|
||||||
import { fileOverlay } from './webpack/overlays/fileOverlay';
|
import { fileOverlay } from './webpack/overlays/fileOverlay';
|
||||||
|
@ -21,7 +21,16 @@ export const webpackOverlays = {
|
||||||
displayBailout: displayBailoutOverlay
|
displayBailout: displayBailoutOverlay
|
||||||
};
|
};
|
||||||
|
|
||||||
export { tsOverlay, htmlOverlay, stylesOverlay, fileOverlay, displayBailoutOverlay, createStylesOverlay };
|
export {
|
||||||
|
tsOverlay,
|
||||||
|
htmlOverlay,
|
||||||
|
stylesOverlay,
|
||||||
|
fileOverlay,
|
||||||
|
displayBailoutOverlay,
|
||||||
|
createStylesOverlay,
|
||||||
|
TsCheckerOptions,
|
||||||
|
TsLoaderOptions
|
||||||
|
};
|
||||||
|
|
||||||
import webpackMerge from 'webpack-merge';
|
import webpackMerge from 'webpack-merge';
|
||||||
export { webpackMerge };
|
export { webpackMerge };
|
||||||
|
|
|
@ -1,24 +1,81 @@
|
||||||
|
import ts from 'typescript';
|
||||||
import { tryRequire } from '../../tryRequire';
|
import { tryRequire } from '../../tryRequire';
|
||||||
|
|
||||||
const ForkTsCheckerPlugin = tryRequire('fork-ts-checker-webpack-plugin');
|
const ForkTsCheckerPlugin = tryRequire('fork-ts-checker-webpack-plugin');
|
||||||
|
|
||||||
export const tsOverlay = () => ({
|
export interface TsLoaderOptions {
|
||||||
resolve: {
|
configFile: string;
|
||||||
extensions: ['.wasm', '.mjs', '.js', '.ts', '.tsx', '.json']
|
transpileOnly: boolean;
|
||||||
},
|
onlyCompileBundledFiles: boolean;
|
||||||
module: {
|
colors: boolean;
|
||||||
rules: [
|
compilerOptions: ts.CompilerOptions;
|
||||||
{
|
happyPackMode: boolean;
|
||||||
test: /\.tsx?$/,
|
getCustomTransformers: string | ((program: ts.Program) => ts.CustomTransformers | undefined);
|
||||||
use: {
|
experimentalWatchApi: boolean;
|
||||||
loader: 'ts-loader',
|
allowTsInNodeModules: boolean;
|
||||||
options: {
|
experimentalFileCaching: boolean;
|
||||||
transpileOnly: true
|
projectReferences: boolean;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
exclude: /node_modules/
|
export interface TsCheckerOptions {
|
||||||
}
|
typescript: string;
|
||||||
]
|
tsconfig: string;
|
||||||
},
|
compilerOptions: object;
|
||||||
plugins: [...(ForkTsCheckerPlugin ? [new ForkTsCheckerPlugin()] : [])]
|
tslint: string | true | undefined;
|
||||||
});
|
tslintAutoFix: boolean;
|
||||||
|
eslint: true | undefined;
|
||||||
|
/** Options to supply to eslint https://eslint.org/docs/1.0.0/developer-guide/nodejs-api#cliengine */
|
||||||
|
eslintOptions: object;
|
||||||
|
watch: string | string[];
|
||||||
|
async: boolean;
|
||||||
|
ignoreDiagnostics: number[];
|
||||||
|
ignoreLints: string[];
|
||||||
|
ignoreLintWarnings: boolean;
|
||||||
|
reportFiles: string[];
|
||||||
|
colors: boolean;
|
||||||
|
silent: boolean;
|
||||||
|
checkSyntacticErrors: boolean;
|
||||||
|
memoryLimit: number;
|
||||||
|
workers: number;
|
||||||
|
vue: boolean;
|
||||||
|
useTypescriptIncrementalApi: boolean;
|
||||||
|
measureCompilationTime: boolean;
|
||||||
|
resolveModuleNameModule: string;
|
||||||
|
resolveTypeReferenceDirectiveModule: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TsOverlayOptions {
|
||||||
|
loaderOptions?: Partial<TsLoaderOptions>;
|
||||||
|
checkerOptions?: Partial<TsCheckerOptions>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const tsOverlay = (overlayOptions?: TsOverlayOptions) => {
|
||||||
|
overlayOptions = overlayOptions || {};
|
||||||
|
|
||||||
|
overlayOptions.loaderOptions = overlayOptions.loaderOptions || {
|
||||||
|
transpileOnly: true
|
||||||
|
};
|
||||||
|
|
||||||
|
overlayOptions.checkerOptions = overlayOptions.loaderOptions || {
|
||||||
|
transpileOnly: true
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.wasm', '.mjs', '.js', '.ts', '.tsx', '.json']
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
use: {
|
||||||
|
loader: 'ts-loader',
|
||||||
|
options: overlayOptions.loaderOptions
|
||||||
|
},
|
||||||
|
exclude: /node_modules/
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [...(ForkTsCheckerPlugin ? [new ForkTsCheckerPlugin(overlayOptions.checkerOptions)] : [])]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче