Skip to content

Commit 53d2dec

Browse files
committed
configure use of per entry compiler
1 parent f28602f commit 53d2dec

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* (improvement) Bump required node version to 12.
3333
* (internal) Bumped all dependencies.
3434
* (improvement) Allow `++` in JS/TS code.
35+
* (feature) Enable separate compiler instances for each entry file by using `enablePerEntryCompilation()`
3536

3637

3738
8.1.0

src/Kaba.ts

+41
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class Kaba
5252
private javaScriptDependenciesFileName: string = "_dependencies";
5353
private hashFileNames: boolean = true;
5454
private buildModern: boolean = true;
55+
private hasPerEntryCompilation: boolean = false;
5556
private nodeSettings: webpack.Node|false = false;
5657

5758

@@ -226,6 +227,16 @@ export class Kaba
226227
}
227228

228229

230+
/**
231+
* Disables the per entry file compilation.
232+
*/
233+
public enablePerEntryCompilation (): this
234+
{
235+
this.hasPerEntryCompilation = true;
236+
return this;
237+
}
238+
239+
229240
/**
230241
* Setting for polyfilling core node packages
231242
*/
@@ -510,6 +521,36 @@ export class Kaba
510521
],
511522
};
512523

524+
if (!this.hasPerEntryCompilation) {
525+
let config = Object.assign({}, configTemplate, {
526+
entry: {
527+
entry: entries,
528+
},
529+
}) as Partial<webpack.Configuration>;
530+
531+
if (!isModule && undefined !== config.module)
532+
{
533+
config.module.rules.push({
534+
// ESLint
535+
test: /\.m?jsx?$/,
536+
// only lint files that are in the project dir & exclude tests, vendor and node_modules
537+
include: (path) => path.startsWith(this.cwd) && !/node_modules|tests|vendor/.test(path),
538+
loader: "eslint-loader",
539+
options: {
540+
cache: true,
541+
configFile: path.join(this.libRoot, "configs/.eslintrc.yml"),
542+
fix: cliConfig.fix,
543+
parser: "babel-eslint",
544+
quiet: !cliConfig.lint,
545+
// always only emit a warning, so to actually never fail the webpack build
546+
emitWarning: true,
547+
},
548+
})
549+
}
550+
551+
return [config]
552+
}
553+
513554
return Object.keys(entries).map(entryFile =>
514555
{
515556
let config = Object.assign({}, configTemplate, {

0 commit comments

Comments
 (0)