Skip to content

Commit 6c6f3a6

Browse files
committed
feat: building update
1 parent 8f3ed9e commit 6c6f3a6

File tree

7 files changed

+281
-145
lines changed

7 files changed

+281
-145
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ DS_STORE
1515
dist
1616
build
1717
lib
18-
./types
18+
types
1919
es
2020
esnext
2121
/data/

babel.config.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
const MIN_BABEL_VERSION = 7;
22

3+
const { NODE_ENV, BABEL_ENV, BABEL_LOOSE } = process.env;
4+
const cjs =
5+
NODE_ENV === 'test' || BABEL_ENV === 'commonjs' || BABEL_ENV === 'cjs';
6+
const es = BABEL_ENV === 'es';
7+
8+
let modules = 'auto';
9+
10+
if (cjs) {
11+
modules = 'commonjs';
12+
} else if (es) {
13+
modules = false;
14+
}
15+
316
module.exports = (api) => {
417
api.assertVersion(MIN_BABEL_VERSION);
518
api.cache(true);
@@ -9,9 +22,8 @@ module.exports = (api) => {
922
[
1023
'@babel/preset-env',
1124
{
12-
targets: {
13-
node: '10.13.0',
14-
},
25+
loose: BABEL_LOOSE,
26+
modules,
1527
},
1628
],
1729
'@babel/preset-typescript',

package.json

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
"version": "1.0.14",
44
"description": "Loader to use config.json file as css variables",
55
"main": "lib/index.js",
6+
"module": "es/index.js",
7+
"esnext": "esnext/index.js",
8+
"types": "types/index.d.ts",
69
"scripts": {
710
"start": "yarn build -- -w",
8-
"build": "rimraf lib && babel src --copy-files --out-dir lib --extensions .ts,.tsx",
11+
"build": "yarn run build:es && yarn run build:esnext && yarn run build:commonjs",
12+
"build:es": "rimraf ./es && BABEL_ENV=es babel --copy-files --out-dir es --extensions .ts,.tsx --ignore '**/*.test.ts,**/__tests__/**' ./src",
13+
"build:esnext": "rimraf ./esnext && tsc -p ./tsconfig.esnext.json",
14+
"build:commonjs": "rimraf ./lib && BABEL_ENV=commonjs babel --copy-files --out-dir lib --extensions .ts,.tsx --ignore '**/*.test.ts,**/__tests__/**' ./src",
15+
"build:types": "rimraf ./types && tsc -p ./tsconfig.types.json",
16+
"postbuild": "yarn run build:types && yarn run rewrite-paths",
17+
"rewrite-paths": "tsconfig-replace-paths -p ./tsconfig.json -s ./src -o ./esnext && tsconfig-replace-paths -p ./tsconfig.json -s ./src -o ./es && tsconfig-replace-paths -p ./tsconfig.json -s ./src -o ./lib",
918
"pack": "yarn build && yarn pack",
1019
"transpile": "tsc -p ./tsconfig.json",
1120
"typecheck": "tsc --noEmit",
@@ -18,7 +27,10 @@
1827
"release:major": "standard-version --release-as major"
1928
},
2029
"files": [
21-
"lib"
30+
"lib",
31+
"es",
32+
"esnext",
33+
"types"
2234
],
2335
"repository": {
2436
"type": "git",
@@ -31,31 +43,35 @@
3143
"@stijnvanhulle:registry": "https://npm.pkg.github.com"
3244
},
3345
"peerDependencies": {
34-
"webpack": "^5.66.0"
46+
"webpack": "^5.67.0"
3547
},
3648
"dependencies": {
3749
"@babel/preset-typescript": "^7.16.7",
3850
"schema-utils": "^4.0.0"
3951
},
4052
"devDependencies": {
4153
"@babel/cli": "^7.16.8",
42-
"@babel/core": "^7.16.7",
54+
"@babel/core": "^7.16.12",
4355
"@babel/polyfill": "^7.12.1",
44-
"@babel/preset-env": "^7.16.8",
45-
"@typescript-eslint/eslint-plugin": "^5.9.1",
46-
"@typescript-eslint/parser": "^5.9.1",
56+
"@babel/preset-env": "^7.16.11",
57+
"@typescript-eslint/eslint-plugin": "^5.10.1",
58+
"@typescript-eslint/parser": "^5.10.1",
4759
"@webpack-contrib/defaults": "^6.3.0",
4860
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
4961
"rimraf": "^3.0.2",
50-
"eslint": "^8.6.0",
62+
"eslint": "^8.8.0",
5163
"eslint-config-prettier": "^8.3.0",
5264
"eslint-plugin-babel": "^5.3.1",
5365
"eslint-plugin-import": "^2.25.4",
5466
"eslint-plugin-prettier": "^4.0.0",
5567
"eslint-plugin-unused-imports": "^2.0.0",
5668
"prettier": "^2.5.1",
5769
"standard-version": "^9.3.2",
58-
"typescript": "^4.5.4",
59-
"webpack": "^5.66.0"
60-
}
70+
"typescript": "^4.5.5",
71+
"tsconfig-replace-paths": "^0.0.11",
72+
"webpack": "^5.67.0"
73+
},
74+
"browserslist": [
75+
"maintained node versions"
76+
]
6177
}

tsconfig.esnext.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"target": "esnext",
5+
"module": "esnext",
6+
"outDir": "esnext",
7+
"baseUrl": ".",
8+
"allowJs": true,
9+
"jsx": "react-native"
10+
},
11+
"include": [
12+
"./src/index.ts",
13+
"./src/**/typings.ts"
14+
],
15+
"exclude": [
16+
"node_modules",
17+
"./src/**/_*/*",
18+
"**/*.test.*",
19+
"**/*.spec.*",
20+
]
21+
}

tsconfig.json

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
4-
"module": "commonjs",
5-
"outDir": "build",
3+
"target": "es6",
4+
"module": "commonjs",
5+
"outDir": "build",
66
"strict": true,
77
"moduleResolution": "node",
8-
"esModuleInterop": true,
8+
"esModuleInterop": true,
99
"strictNullChecks": true,
1010
"declaration": false,
1111
"experimentalDecorators": true,
1212
"skipLibCheck": true,
1313
"baseUrl": ".",
1414
"resolveJsonModule": true,
1515
"allowJs": true,
16-
"typeRoots": [
17-
"node_modules/@types",
18-
"typings"
19-
],
20-
"types": [
21-
"node"
22-
],
16+
"typeRoots": ["node_modules/@types", "typings"],
17+
"types": ["node"],
18+
"paths": {}
2319
},
24-
"include": [
25-
"./src/**/*",
26-
],
27-
"exclude":[
28-
"node_modules"
29-
]
30-
}
20+
"include": ["./src/**/*"],
21+
"exclude": ["node_modules"]
22+
}

tsconfig.types.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"declaration": true,
5+
"declarationDir": "./types",
6+
"emitDeclarationOnly": true,
7+
"noEmit": false
8+
},
9+
"include": [
10+
"./src/index.ts",
11+
"./src/**/typings.ts"
12+
],
13+
"exclude": [
14+
"node_modules",
15+
"./src/**/_*/*",
16+
"**/*.test.*",
17+
"**/*.spec.*",
18+
]
19+
}

0 commit comments

Comments
 (0)