Skip to content

Commit ab7dd02

Browse files
author
Jannik Zschiesche
authored
Merge pull request #110 from Becklyn/next
Go back to include list + bump dependencies
2 parents 15857d6 + 4fa9aff commit ab7dd02

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* (improvement) The code is now always compiled per entry file
3535
* (improvement) Build TypeScript for the `esnext` module system, that (amongst other things) allows to use `import()`.
3636
* (bug) Compile every entry into a separate directory, to avoid issues with the clean plugin.
37-
* (bc) Now you can defined which packages in `node_modules` should NOT be transformed. Use `.ignoreNpmPackages(...)`.
37+
* (bc) Not all npm packages are automatically transpiled anymore. You need to define which packages from `node_modules` to transpile via Babel by using `.compileNpmPackages(...)`.
3838
* (feature) Even if not recommended (use SCSS!), we now support compiling CSS via webpack (not as entry point though). The CSS will be injected into the head dynamically.
3939

4040

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
"test": "npm run-script build && ava"
2020
},
2121
"optionalDependencies": {
22-
"kaba-scss": "^3.3.2",
22+
"kaba-scss": "^3.3.5",
2323
"webpack-bundle-analyzer": "^3.6.0"
2424
},
2525
"dependencies": {
26-
"@babel/core": "^7.8.3",
26+
"@babel/core": "^7.8.4",
2727
"@becklyn/typescript-error-formatter": "^1.0.4",
2828
"babel-eslint": "^10.0.3",
2929
"babel-loader": "^8.0.6",
@@ -32,27 +32,27 @@
3232
"duplicate-package-checker-webpack-plugin": "^3.0.0",
3333
"eslint": "^6.8.0",
3434
"eslint-loader": "^3.0.3",
35-
"eslint-plugin-jsdoc": "^20.3.0",
36-
"eslint-plugin-react": "^7.17.0",
35+
"eslint-plugin-jsdoc": "^21.0.0",
36+
"eslint-plugin-react": "^7.18.3",
3737
"eslint-plugin-react-hooks": "^2.3.0",
3838
"fs-extra": "^8.1.0",
39-
"kaba-babel-preset": "^4.1.1",
39+
"kaba-babel-preset": "^4.1.2",
4040
"kleur": "^3.0.3",
4141
"postcss-loader": "^3.0.0",
4242
"pretty-hrtime": "^1.0.3",
4343
"progress-bar-webpack-plugin": "^2.1.0",
4444
"raw-loader": "^4.0.0",
4545
"sade": "^1.7.0",
4646
"style-loader": "^1.1.3",
47-
"terser-webpack-plugin": "^2.3.2",
47+
"terser-webpack-plugin": "^2.3.4",
4848
"ts-loader": "^6.2.1",
49-
"typescript": "^3.7.4",
49+
"typescript": "^3.7.5",
5050
"webpack": "^4.41.5"
5151
},
5252
"devDependencies": {
5353
"@types/terser-webpack-plugin": "^2.2.0",
5454
"ava": "^2.4.0",
55-
"kaba-scss": "^3.3.2",
55+
"kaba-scss": "^3.3.5",
5656
"webpack-bundle-analyzer": "^3.6.0"
5757
},
5858
"engines": {

src/Kaba.ts

+19-21
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ProgressBarPlugin = require('progress-bar-webpack-plugin');
1212
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
1313

1414
const PACKAGE_MATCHER = /\/node_modules\/(?<package>(?:@[^@\/]+\/)?[^@\/]+)\//;
15-
type IgnoredNpmPackagesMapping = Array<RegExp|string>;
15+
type CompiledNpmPackagesMapping = Array<RegExp|string>;
1616
const ignoredPackagesCache: {[k: string]: boolean} = {};
1717
interface PostCssLoaderOptions {[key: string]: any}
1818

@@ -36,7 +36,7 @@ interface Externals
3636
/**
3737
* Determines whether a file should processed by the asset pipeline.
3838
*/
39-
function isAllowedPath (path: string, ignoredPackages: IgnoredNpmPackagesMapping) : boolean
39+
function isAllowedPath (path: string, compiledPackages: CompiledNpmPackagesMapping) : boolean
4040
{
4141
const match = PACKAGE_MATCHER.exec(path);
4242

@@ -53,25 +53,25 @@ function isAllowedPath (path: string, ignoredPackages: IgnoredNpmPackagesMapping
5353
return ignoredPackagesCache[packageNameToCompile];
5454
}
5555

56-
const length = ignoredPackages.length;
56+
const length = compiledPackages.length;
5757
for (let i = 0; i < length; ++i)
5858
{
59-
const ignoredPackage = ignoredPackages[i];
59+
const compiledPackage = compiledPackages[i];
6060

61-
if (typeof ignoredPackage == "string")
61+
if (typeof compiledPackage == "string")
6262
{
63-
if (ignoredPackage === packageNameToCompile)
63+
if (compiledPackage === packageNameToCompile)
6464
{
65-
return ignoredPackagesCache[packageNameToCompile] = false;
65+
return ignoredPackagesCache[packageNameToCompile] = true;
6666
}
6767
}
68-
else if (ignoredPackage.test(packageNameToCompile))
68+
else if (compiledPackage.test(packageNameToCompile))
6969
{
70-
return ignoredPackagesCache[packageNameToCompile] = false;
70+
return ignoredPackagesCache[packageNameToCompile] = true;
7171
}
7272
}
7373

74-
return ignoredPackagesCache[packageNameToCompile] = true;
74+
return ignoredPackagesCache[packageNameToCompile] = false;
7575
}
7676

7777
/**
@@ -96,11 +96,10 @@ export class Kaba
9696
private hashFileNames: boolean = true;
9797
private buildModern: boolean = true;
9898
private nodeSettings: webpack.Node|false = false;
99-
private ignoredNpmPackages: IgnoredNpmPackagesMapping = [
100-
/^@babel/,
101-
/^babel-/,
102-
/^core-js(-|$)/,
103-
/^regenerator-/,
99+
private compiledNpmPackages: CompiledNpmPackagesMapping = [
100+
/^@becklyn/,
101+
/^@mayd/,
102+
/^mojave/,
104103
];
105104
private postCssLoaderOptions: PostCssLoaderOptions = {};
106105

@@ -129,11 +128,11 @@ export class Kaba
129128

130129

131130
/**
132-
* Defines which npm packages are NOT compiled with babel
131+
* Defines which npm packages are compiled with babel.
133132
*/
134-
public ignoreNpmPackages (modules: Array<string|RegExp>): this
133+
public compileNpmPackages (modules: Array<string|RegExp>): this
135134
{
136-
this.ignoredNpmPackages = this.ignoredNpmPackages.concat(modules);
135+
this.compiledNpmPackages = this.compiledNpmPackages.concat(modules);
137136
return this;
138137
}
139138

@@ -401,7 +400,6 @@ export class Kaba
401400
"node_modules",
402401
],
403402

404-
// TS is potentially added below
405403
extensions: [
406404
".mjs",
407405
".mjsx",
@@ -439,14 +437,14 @@ export class Kaba
439437
},
440438
},
441439
],
442-
include: (path: string) => isAllowedPath(path, this.ignoredNpmPackages),
440+
include: (path: string) => isAllowedPath(path, this.compiledNpmPackages),
443441
},
444442

445443
// Babel
446444
{
447445
test: /\.m?jsx?$/,
448446
use: [babelLoader],
449-
include: (path: string) => isAllowedPath(path, this.ignoredNpmPackages),
447+
include: (path: string) => isAllowedPath(path, this.compiledNpmPackages),
450448
},
451449

452450
// content files

0 commit comments

Comments
 (0)