@nlabs/lex 1.39.0 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +1 -0
- package/.vscode/settings.json +1 -1
- package/babel.config.json +13 -0
- package/dist/LexConfig.js +40 -36
- package/dist/commands/build.js +98 -52
- package/dist/commands/bulid.test.js +314 -5
- package/dist/commands/clean.js +4 -4
- package/dist/commands/clean.test.js +63 -0
- package/dist/commands/compile.js +32 -35
- package/dist/commands/compile.test.js +93 -0
- package/dist/commands/config.js +4 -4
- package/dist/commands/copy.js +1 -1
- package/dist/commands/create.js +10 -10
- package/dist/commands/dev.js +12 -12
- package/dist/commands/init.js +17 -17
- package/dist/commands/link.js +3 -3
- package/dist/commands/lint.js +53 -39
- package/dist/commands/migrate.js +4 -4
- package/dist/commands/publish.js +7 -7
- package/dist/commands/test.js +14 -14
- package/dist/commands/update.js +10 -10
- package/dist/commands/upgrade.js +7 -7
- package/dist/commands/versions.js +8 -9
- package/dist/commands/versions.test.js +49 -0
- package/dist/create/changelog.js +3 -3
- package/dist/lex.js +16 -16
- package/dist/lint.js +8 -0
- package/dist/utils/app.js +1 -1
- package/dist/utils/file.js +20 -10
- package/jest.config.cjs +55 -0
- package/jest.config.lex.js +27 -28
- package/jest.setup.ts +3 -0
- package/package.json +76 -71
- package/resolver.cjs +86 -0
- package/test/javascript.js +6 -0
- package/test/typescript.ts +6 -0
- package/tsconfig.build.json +1 -1
- package/tsconfig.json +1 -1
- package/tsconfig.template.json +5 -5
- package/webpack.config.js +78 -65
- package/dist/resolver.js +0 -70
- package/jest.config.js +0 -14
- package/jest.setup.js +0 -3
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nlabs/lex",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "Lex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"bin":
|
|
8
|
-
"lex": "./dist/lex.js"
|
|
9
|
-
},
|
|
7
|
+
"bin": "./dist/lex.js",
|
|
10
8
|
"keywords": [
|
|
11
9
|
"arkhamjs",
|
|
12
10
|
"lex",
|
|
@@ -27,128 +25,135 @@
|
|
|
27
25
|
"url": "https://github.com/nitrogenlabs/lex/issues"
|
|
28
26
|
},
|
|
29
27
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
28
|
+
"node": ">=20"
|
|
31
29
|
},
|
|
32
|
-
"browserslist": [
|
|
33
|
-
"last 5 version",
|
|
34
|
-
"ie 11"
|
|
35
|
-
],
|
|
36
30
|
"scripts": {
|
|
37
|
-
"build": "NODE_ENV=production && rm -rf dist && esbuild src/**/**.ts* src/**.ts* --platform=node --outdir=./dist --sourcemap=inline --target=esnext --format=esm",
|
|
31
|
+
"build": "NODE_ENV=production && rm -rf dist && esbuild ./src/**/**.ts* ./src/**.ts* --platform=node --outdir=./dist --sourcemap=inline --target=esnext --format=esm --packages=external",
|
|
38
32
|
"clean": "rm -rf dist node_modules package-lock.json *.log coverage",
|
|
39
33
|
"compile": "tsc -p tsconfig.build.json",
|
|
40
34
|
"env": "LEX_CONFIG='{\"useTypescript\":true}'",
|
|
41
35
|
"lint": "eslint ./src --ext .ts,.tsx",
|
|
42
|
-
"prepublishOnly": "
|
|
36
|
+
"prepublishOnly": "npm run build",
|
|
43
37
|
"publish:major": "npm version major && npm publish",
|
|
44
38
|
"publish:minor": "npm version minor && npm publish",
|
|
45
39
|
"publish:patch": "npm version patch && npm publish",
|
|
46
40
|
"reset": "rm -rf node_modules packages-lock.json",
|
|
47
|
-
"test": "
|
|
48
|
-
"update": "
|
|
49
|
-
"watch": "NODE_ENV=development rm -rf dist &&
|
|
41
|
+
"test": "NODE_ENV=test && npm run lint && npm run env && jest",
|
|
42
|
+
"update": "npm-check-updates -i",
|
|
43
|
+
"watch": "NODE_ENV=development rm -rf dist && npm run compile -w"
|
|
50
44
|
},
|
|
51
45
|
"dependencies": {
|
|
46
|
+
"@babel/core": "^7.23.6",
|
|
47
|
+
"@babel/preset-env": "^7.23.6",
|
|
48
|
+
"@babel/preset-typescript": "7.23.3",
|
|
52
49
|
"@luckycatfactory/esbuild-graphql-loader": "^3.8.1",
|
|
53
|
-
"@nlabs/
|
|
50
|
+
"@nlabs/execa-mock": "^1.39.1",
|
|
54
51
|
"@nlabs/gothamjs": "^0.8.2",
|
|
55
52
|
"@nlabs/webpack-plugin-static-site": "^0.1.1",
|
|
56
|
-
"acorn": "^8.
|
|
53
|
+
"acorn": "^8.11.2",
|
|
57
54
|
"acorn-dynamic-import": "^4.0.0",
|
|
58
|
-
"assert": "^2.
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
55
|
+
"assert": "^2.1.0",
|
|
56
|
+
"autoprefixer": "^10.4.16",
|
|
57
|
+
"babel-jest": "^29.7.0",
|
|
58
|
+
"boxen": "7.1.1",
|
|
59
|
+
"caniuse-lite": "1.0.30001572",
|
|
60
|
+
"chalk": "^5.3.0",
|
|
61
|
+
"commander": "^11.1.0",
|
|
62
|
+
"compare-versions": "^6.1.0",
|
|
64
63
|
"compression-webpack-plugin": "^10.0.0",
|
|
65
64
|
"config-webpack-plugin": "^1.1.0",
|
|
66
65
|
"copy-webpack-plugin": "^11.0.0",
|
|
67
|
-
"core-js": "^3.
|
|
66
|
+
"core-js": "^3.34.0",
|
|
68
67
|
"crypto-browserify": "^3.12.0",
|
|
69
|
-
"css-loader": "^6.
|
|
70
|
-
"cssnano": "^
|
|
68
|
+
"css-loader": "^6.8.1",
|
|
69
|
+
"cssnano": "^6.0.2",
|
|
71
70
|
"dotenv-webpack": "^8.0.1",
|
|
72
71
|
"download-npm-package": "^3.1.12",
|
|
73
|
-
"esbuild": "
|
|
74
|
-
"esbuild-loader": "
|
|
75
|
-
"execa": "
|
|
72
|
+
"esbuild": "0.19.10",
|
|
73
|
+
"esbuild-loader": "4.0.2",
|
|
74
|
+
"execa": "8.0.1",
|
|
76
75
|
"exports-loader": "^4.0.0",
|
|
77
|
-
"favicons-webpack-plugin": "^6.0.
|
|
76
|
+
"favicons-webpack-plugin": "^6.0.1",
|
|
78
77
|
"file-loader": "^6.2.0",
|
|
79
78
|
"find-file-up": "^2.0.1",
|
|
80
|
-
"glob": "^
|
|
81
|
-
"graphql": "^16.
|
|
79
|
+
"glob": "^10.3.10",
|
|
80
|
+
"graphql": "^16.8.1",
|
|
82
81
|
"graphql-tag": "^2.12.6",
|
|
83
82
|
"html-loader": "^4.2.0",
|
|
84
|
-
"html-webpack-plugin": "^5.
|
|
83
|
+
"html-webpack-plugin": "^5.6.0",
|
|
85
84
|
"https-browserify": "^1.0.0",
|
|
86
85
|
"imports-loader": "^4.0.1",
|
|
87
|
-
"jest": "
|
|
88
|
-
"jest-circus": "
|
|
89
|
-
"jest-cli": "
|
|
90
|
-
"jest-environment-jsdom": "
|
|
91
|
-
"jest-transform-graphql": "
|
|
92
|
-
"json-d-ts": "
|
|
86
|
+
"jest": "29.7.0",
|
|
87
|
+
"jest-circus": "29.7.0",
|
|
88
|
+
"jest-cli": "29.7.0",
|
|
89
|
+
"jest-environment-jsdom": "29.7.0",
|
|
90
|
+
"jest-transform-graphql": "2.1.0",
|
|
91
|
+
"json-d-ts": "1.0.1",
|
|
93
92
|
"latest-version": "7.0.0",
|
|
94
93
|
"lodash": "^4.17.21",
|
|
95
|
-
"luxon": "^3.
|
|
94
|
+
"luxon": "^3.4.4",
|
|
96
95
|
"net": "^1.0.2",
|
|
97
|
-
"
|
|
98
|
-
"ora": "6.2.0",
|
|
96
|
+
"ora": "8.0.1",
|
|
99
97
|
"os-browserify": "^0.3.0",
|
|
100
98
|
"path-browserify": "^1.0.1",
|
|
101
|
-
"postcss-browser-reporter": "^0.
|
|
102
|
-
"postcss-cli": "^
|
|
103
|
-
"postcss-custom-properties": "^13.
|
|
99
|
+
"postcss-browser-reporter": "^0.7.0",
|
|
100
|
+
"postcss-cli": "^11.0.0",
|
|
101
|
+
"postcss-custom-properties": "^13.3.3",
|
|
104
102
|
"postcss-flexbugs-fixes": "^5.0.2",
|
|
105
103
|
"postcss-for": "^2.1.1",
|
|
106
104
|
"postcss-hash": "^3.0.0",
|
|
107
105
|
"postcss-import": "15.1.0",
|
|
108
|
-
"postcss-loader": "^7.
|
|
109
|
-
"postcss-nesting": "^
|
|
106
|
+
"postcss-loader": "^7.3.4",
|
|
107
|
+
"postcss-nesting": "^12.0.2",
|
|
110
108
|
"postcss-percentage": "^0.0.0",
|
|
111
|
-
"postcss-preset-env": "^
|
|
109
|
+
"postcss-preset-env": "^9.3.0",
|
|
112
110
|
"postcss-simple-vars": "^7.0.1",
|
|
113
|
-
"postcss-svgo": "
|
|
111
|
+
"postcss-svgo": "6.0.1",
|
|
114
112
|
"postcss-url": "10.1.3",
|
|
115
113
|
"process": "^0.11.10",
|
|
116
|
-
"react": "^18.
|
|
117
|
-
"react-dom": "^18.
|
|
118
|
-
"regenerator-runtime": "^0.
|
|
119
|
-
"resolve": "^1.22.
|
|
120
|
-
"rimraf": "^
|
|
121
|
-
"semver": "^7.
|
|
122
|
-
"source-map-loader": "^4.0.
|
|
114
|
+
"react": "^18.2.0",
|
|
115
|
+
"react-dom": "^18.2.0",
|
|
116
|
+
"regenerator-runtime": "^0.14.1",
|
|
117
|
+
"resolve": "^1.22.8",
|
|
118
|
+
"rimraf": "^5.0.5",
|
|
119
|
+
"semver": "^7.5.4",
|
|
120
|
+
"source-map-loader": "^4.0.2",
|
|
123
121
|
"source-map-support": "^0.5.21",
|
|
124
122
|
"speed-measure-webpack-plugin": "^1.5.0",
|
|
125
123
|
"static-site-generator-webpack-plugin": "^3.4.2",
|
|
126
124
|
"stream-browserify": "^3.0.0",
|
|
127
125
|
"stream-http": "^3.2.0",
|
|
128
|
-
"style-loader": "^3.3.
|
|
129
|
-
"svg-spritemap-webpack-plugin": "^4.
|
|
130
|
-
"svgo": "3.0
|
|
126
|
+
"style-loader": "^3.3.3",
|
|
127
|
+
"svg-spritemap-webpack-plugin": "^4.5.0",
|
|
128
|
+
"svgo": "3.1.0",
|
|
131
129
|
"tls": "^0.0.1",
|
|
132
|
-
"
|
|
130
|
+
"ts-jest": "29.1.1",
|
|
131
|
+
"ts-node": "^10.9.2",
|
|
132
|
+
"typescript": "5.3.3",
|
|
133
133
|
"url-loader": "^4.1.1",
|
|
134
134
|
"util": "^0.12.5",
|
|
135
|
-
"webpack": "5.
|
|
136
|
-
"webpack-bundle-analyzer": "^4.
|
|
137
|
-
"webpack-cli": "^5.
|
|
138
|
-
"webpack-merge": "^5.
|
|
135
|
+
"webpack": "5.89.0",
|
|
136
|
+
"webpack-bundle-analyzer": "^4.10.1",
|
|
137
|
+
"webpack-cli": "^5.1.4",
|
|
138
|
+
"webpack-merge": "^5.10.0",
|
|
139
139
|
"webpack-nano": "^1.1.1",
|
|
140
140
|
"webpack-plugin-serve": "^1.6.0"
|
|
141
141
|
},
|
|
142
142
|
"devDependencies": {
|
|
143
|
-
"@
|
|
144
|
-
"@
|
|
145
|
-
"@
|
|
146
|
-
"@types/
|
|
143
|
+
"@babel/plugin-transform-runtime": "^7.23.6",
|
|
144
|
+
"@babel/preset-react": "^7.23.3",
|
|
145
|
+
"@nlabs/execa-mock": "^1.39.1",
|
|
146
|
+
"@types/jest": "^29.5.11",
|
|
147
|
+
"@types/luxon": "^3.3.7",
|
|
148
|
+
"@types/node": "^20.10.5",
|
|
147
149
|
"@types/ora": "^3.2.0",
|
|
148
|
-
"@types/react": "^18.
|
|
149
|
-
"@types/webpack": "^5.28.
|
|
150
|
-
"
|
|
151
|
-
"
|
|
150
|
+
"@types/react": "^18.2.45",
|
|
151
|
+
"@types/webpack": "^5.28.5",
|
|
152
|
+
"babel-plugin-transform-import-meta": "^2.2.1",
|
|
153
|
+
"babel-plugin-transform-vite-meta-env": "^1.0.3",
|
|
154
|
+
"eslint": "^8.56.0",
|
|
155
|
+
"eslint-config-styleguidejs": "^3.2.1",
|
|
156
|
+
"npm-check-updates": "^16.14.12"
|
|
152
157
|
},
|
|
153
158
|
"gitHead": "0f5fb22fc0f0ab1abab5adf62afed24c7c87e4a8"
|
|
154
159
|
}
|
package/resolver.cjs
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-Present, Nitrogen Labs, Inc.
|
|
3
|
+
* Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
|
|
4
|
+
*/
|
|
5
|
+
const {existsSync} = require('fs');
|
|
6
|
+
const {extname: pathExtname, resolve: pathResolve} = require('path');
|
|
7
|
+
const resolveSync = require('resolve/sync');
|
|
8
|
+
|
|
9
|
+
const getFullPath = (basedir, name, extensions) => {
|
|
10
|
+
let fileName = name;
|
|
11
|
+
|
|
12
|
+
extensions.some((ext) => {
|
|
13
|
+
if(fileName !== '..') {
|
|
14
|
+
const fullPath = pathResolve(`${basedir}/${fileName}${ext}`);
|
|
15
|
+
|
|
16
|
+
if(existsSync(fullPath)) {
|
|
17
|
+
fileName = fullPath;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if(fileName !== 'index') {
|
|
23
|
+
const indexFile = pathResolve(`${basedir}/${fileName}/index${ext}`);
|
|
24
|
+
|
|
25
|
+
if(existsSync(indexFile)) {
|
|
26
|
+
fileName = indexFile;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return false;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return fileName;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = (value, options) => {
|
|
38
|
+
let fileName = value;
|
|
39
|
+
|
|
40
|
+
if(fileName === '') {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const isSequencer = fileName.startsWith('jest-sequencer-');
|
|
45
|
+
|
|
46
|
+
if(isSequencer) {
|
|
47
|
+
fileName = fileName.replace('jest-sequencer-', '');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const {basedir, extensions = ['.js', '.ts']} = options;
|
|
51
|
+
const existingExt = pathExtname(fileName) || '';
|
|
52
|
+
const hasExtension = existingExt !== '' && extensions.includes(existingExt);
|
|
53
|
+
const isAbsolute = fileName.indexOf('/') === 0;
|
|
54
|
+
|
|
55
|
+
if(isAbsolute) {
|
|
56
|
+
if(hasExtension) {
|
|
57
|
+
return existsSync(fileName) ? fileName : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return getFullPath(fileName, 'index', extensions);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if(fileName === '..') {
|
|
64
|
+
return getFullPath(basedir, '..', extensions);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const hasBase = fileName.indexOf('./') >= 0 || fileName.indexOf('../') >= 0;
|
|
68
|
+
|
|
69
|
+
if(hasBase) {
|
|
70
|
+
if(hasExtension) {
|
|
71
|
+
return pathResolve(`${basedir}/${fileName}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return getFullPath(basedir, fileName, extensions);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
return resolveSync(fileName, {basedir: `${__dirname}/../`, extensions});
|
|
79
|
+
} catch(error) {
|
|
80
|
+
try {
|
|
81
|
+
return resolveSync(fileName, {basedir: process.cwd(), extensions});
|
|
82
|
+
} catch(error) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
package/tsconfig.template.json
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"allowJs": false,
|
|
4
4
|
"allowSyntheticDefaultImports": true,
|
|
5
|
-
"
|
|
5
|
+
"emitDeclarationOnly": true,
|
|
6
6
|
"esModuleInterop": true,
|
|
7
7
|
"inlineSourceMap": true,
|
|
8
8
|
"jsx": "react-jsx",
|
|
9
9
|
"lib": [
|
|
10
10
|
"es6",
|
|
11
11
|
"es7",
|
|
12
|
-
"
|
|
12
|
+
"ESNext",
|
|
13
13
|
"dom"
|
|
14
14
|
],
|
|
15
|
-
"module": "
|
|
16
|
-
"moduleResolution": "
|
|
15
|
+
"module": "ESNext",
|
|
16
|
+
"moduleResolution": "Node",
|
|
17
17
|
"noFallthroughCasesInSwitch": true,
|
|
18
18
|
"noImplicitReturns": true,
|
|
19
19
|
"noImplicitThis": true,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"pretty": true,
|
|
22
22
|
"removeComments": true,
|
|
23
23
|
"skipLibCheck": true,
|
|
24
|
-
"target": "
|
|
24
|
+
"target": "ESNext",
|
|
25
25
|
"types": [
|
|
26
26
|
"jest",
|
|
27
27
|
"node"
|
package/webpack.config.js
CHANGED
|
@@ -2,28 +2,41 @@
|
|
|
2
2
|
* Copyright (c) 2018-Present, Nitrogen Labs, Inc.
|
|
3
3
|
* Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
import {StaticSitePlugin} from '@nlabs/webpack-plugin-static-site';
|
|
6
|
+
import autoprefixer from 'autoprefixer';
|
|
7
|
+
import CompressionWebpackPlugin from 'compression-webpack-plugin';
|
|
8
|
+
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
|
9
|
+
import cssnano from 'cssnano';
|
|
10
|
+
import DotenvPlugin from 'dotenv-webpack';
|
|
11
|
+
import {EsbuildPlugin} from 'esbuild-loader';
|
|
12
|
+
import FaviconsWebpackPlugin from 'favicons-webpack-plugin';
|
|
13
|
+
import {existsSync} from 'fs';
|
|
14
|
+
import {sync as globSync} from 'glob';
|
|
15
|
+
import HtmlWebPackPlugin from 'html-webpack-plugin';
|
|
16
|
+
import isEmpty from 'lodash/isEmpty.js';
|
|
17
|
+
import {resolve as pathResolve} from 'path';
|
|
18
|
+
import postcssBrowserReporter from 'postcss-browser-reporter';
|
|
19
|
+
import postcssCustomProperties from 'postcss-custom-properties';
|
|
20
|
+
import postcssFlexbugsFixes from 'postcss-flexbugs-fixes';
|
|
21
|
+
import postcssFor from 'postcss-for';
|
|
22
|
+
import postcssImport from 'postcss-import';
|
|
23
|
+
import postcssNesting from 'postcss-nesting';
|
|
24
|
+
import postcssPercentage from 'postcss-percentage';
|
|
25
|
+
import postcssPresetEnv from 'postcss-preset-env';
|
|
26
|
+
import postcssUrl from 'postcss-url';
|
|
27
|
+
import SVGSpritemapPlugin from 'svg-spritemap-webpack-plugin';
|
|
28
|
+
import {URL} from 'url';
|
|
29
|
+
import {default as webpack} from 'webpack';
|
|
30
|
+
import {BundleAnalyzerPlugin} from 'webpack-bundle-analyzer';
|
|
31
|
+
import {merge} from 'webpack-merge';
|
|
32
|
+
import {WebpackPluginServe} from 'webpack-plugin-serve';
|
|
21
33
|
|
|
22
|
-
|
|
34
|
+
import {relativeFilePath, relativeNodePath} from './dist/utils/file.js';
|
|
23
35
|
|
|
24
36
|
const {ProgressPlugin, ProvidePlugin} = webpack;
|
|
25
37
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
26
38
|
const lexConfig = JSON.parse(process.env.LEX_CONFIG) || {};
|
|
39
|
+
const dirName = new URL('.', import.meta.url).pathname;
|
|
27
40
|
|
|
28
41
|
const {
|
|
29
42
|
isStatic,
|
|
@@ -47,7 +60,7 @@ const plugins = [
|
|
|
47
60
|
dependencies: true,
|
|
48
61
|
percentBy: null
|
|
49
62
|
}),
|
|
50
|
-
new DotenvPlugin({path:
|
|
63
|
+
new DotenvPlugin({path: pathResolve(process.cwd(), '.env'), systemvars: false})
|
|
51
64
|
];
|
|
52
65
|
|
|
53
66
|
const isWeb = (preset || targetEnvironment) === 'web';
|
|
@@ -58,7 +71,7 @@ if(isWeb) {
|
|
|
58
71
|
new CompressionWebpackPlugin({algorithm: 'gzip'}),
|
|
59
72
|
new ProvidePlugin({
|
|
60
73
|
process: 'process/browser',
|
|
61
|
-
React:
|
|
74
|
+
React: pathResolve(dirName, './node_modules/react')
|
|
62
75
|
})
|
|
63
76
|
);
|
|
64
77
|
}
|
|
@@ -73,7 +86,7 @@ const globOptions = {
|
|
|
73
86
|
|
|
74
87
|
const svgPaths = `${sourceFullPath}/icons/**/**.svg`;
|
|
75
88
|
|
|
76
|
-
if(
|
|
89
|
+
if(globSync(svgPaths, globOptions).length) {
|
|
77
90
|
plugins.push(new SVGSpritemapPlugin(svgPaths, {
|
|
78
91
|
input: {
|
|
79
92
|
allowDuplicates: false
|
|
@@ -95,17 +108,17 @@ const imagePath = `${sourceFullPath}/images/`;
|
|
|
95
108
|
const fontPath = `${sourceFullPath}/fonts/`;
|
|
96
109
|
const docPath = `${sourceFullPath}/docs/`;
|
|
97
110
|
|
|
98
|
-
if(
|
|
111
|
+
if(existsSync(imagePath)) {
|
|
99
112
|
staticPaths.push({from: imagePath, to: './images/'});
|
|
100
113
|
watchIgnorePaths.push(imagePath);
|
|
101
114
|
}
|
|
102
115
|
|
|
103
|
-
if(
|
|
116
|
+
if(existsSync(fontPath)) {
|
|
104
117
|
staticPaths.push({from: fontPath, to: './fonts/'});
|
|
105
118
|
watchIgnorePaths.push(fontPath);
|
|
106
119
|
}
|
|
107
120
|
|
|
108
|
-
if(
|
|
121
|
+
if(existsSync(docPath)) {
|
|
109
122
|
staticPaths.push({from: docPath, to: './docs/'});
|
|
110
123
|
}
|
|
111
124
|
|
|
@@ -113,7 +126,7 @@ if(staticPaths.length) {
|
|
|
113
126
|
plugins.push(new CopyWebpackPlugin({patterns: staticPaths}));
|
|
114
127
|
}
|
|
115
128
|
|
|
116
|
-
if(
|
|
129
|
+
if(existsSync(`${sourceFullPath}/${lexConfig.entryHTML}`)) {
|
|
117
130
|
plugins.push(new HtmlWebPackPlugin({
|
|
118
131
|
filename: './index.html',
|
|
119
132
|
minify: isProduction,
|
|
@@ -134,26 +147,26 @@ if(outputFile) {
|
|
|
134
147
|
}
|
|
135
148
|
|
|
136
149
|
// Loader paths
|
|
137
|
-
const esbuildLoaderPath =
|
|
138
|
-
const cssLoaderPath =
|
|
139
|
-
const fileLoaderPath =
|
|
140
|
-
const graphqlLoaderPath =
|
|
141
|
-
const htmlLoaderPath =
|
|
142
|
-
const jsonLoaderPath =
|
|
143
|
-
const postcssLoaderPath =
|
|
144
|
-
const sourceMapLoaderPath =
|
|
145
|
-
const styleLoaderPath =
|
|
146
|
-
const webpackPath =
|
|
150
|
+
const esbuildLoaderPath = relativeNodePath('esbuild-loader', dirName);
|
|
151
|
+
const cssLoaderPath = relativeNodePath('css-loader', dirName);
|
|
152
|
+
const fileLoaderPath = relativeNodePath('file-loader', dirName);
|
|
153
|
+
const graphqlLoaderPath = relativeNodePath('graphql-tag/loader', dirName);
|
|
154
|
+
const htmlLoaderPath = relativeNodePath('html-loader', dirName);
|
|
155
|
+
const jsonLoaderPath = relativeNodePath('json-loader', dirName);
|
|
156
|
+
const postcssLoaderPath = relativeNodePath('postcss-loader', dirName);
|
|
157
|
+
const sourceMapLoaderPath = relativeNodePath('source-map-loader', dirName);
|
|
158
|
+
const styleLoaderPath = relativeNodePath('style-loader', dirName);
|
|
159
|
+
const webpackPath = relativeNodePath('webpack', dirName);
|
|
147
160
|
|
|
148
161
|
// Aliases
|
|
149
162
|
const aliasPaths = {
|
|
150
|
-
'@nlabs/arkhamjs':
|
|
151
|
-
'@nlabs/arkhamjs-utils-react':
|
|
152
|
-
'core-js':
|
|
153
|
-
process:
|
|
154
|
-
react:
|
|
155
|
-
'react-dom':
|
|
156
|
-
'regenerator-runtime':
|
|
163
|
+
'@nlabs/arkhamjs': relativeNodePath('@nlabs/arkhamjs', process.cwd()),
|
|
164
|
+
'@nlabs/arkhamjs-utils-react': relativeNodePath('@nlabs/arkhamjs-utils-react', process.cwd()),
|
|
165
|
+
'core-js': relativeNodePath('core-js', dirName),
|
|
166
|
+
process: relativeNodePath('process', dirName),
|
|
167
|
+
react: relativeNodePath('react', process.cwd()),
|
|
168
|
+
'react-dom': relativeNodePath('react-dom', process.cwd()),
|
|
169
|
+
'regenerator-runtime': relativeNodePath('regenerator-runtime', dirName)
|
|
157
170
|
};
|
|
158
171
|
const aliasKeys = Object.keys(aliasPaths);
|
|
159
172
|
const alias = aliasKeys.reduce((aliases, key) => {
|
|
@@ -165,7 +178,7 @@ const alias = aliasKeys.reduce((aliases, key) => {
|
|
|
165
178
|
}, {});
|
|
166
179
|
|
|
167
180
|
// Webpack config
|
|
168
|
-
|
|
181
|
+
export default (webpackEnv, webpackOptions) => {
|
|
169
182
|
const {bundleAnalyzer, watch} = webpackOptions;
|
|
170
183
|
const webpackConfig = {
|
|
171
184
|
bail: true,
|
|
@@ -235,27 +248,27 @@ module.exports = (webpackEnv, webpackOptions) => {
|
|
|
235
248
|
options: {
|
|
236
249
|
postcssOptions: {
|
|
237
250
|
plugins: [
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
251
|
+
postcssImport({addDependencyTo: webpack}),
|
|
252
|
+
postcssUrl,
|
|
253
|
+
postcssFor,
|
|
254
|
+
postcssPercentage({
|
|
242
255
|
floor: true,
|
|
243
256
|
precision: 9,
|
|
244
257
|
trimTrailingZero: true
|
|
245
258
|
}),
|
|
246
|
-
|
|
259
|
+
postcssCustomProperties({
|
|
247
260
|
preserve: false,
|
|
248
261
|
strict: false,
|
|
249
262
|
warnings: false
|
|
250
263
|
}),
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
264
|
+
autoprefixer,
|
|
265
|
+
postcssNesting,
|
|
266
|
+
postcssFlexbugsFixes,
|
|
267
|
+
postcssPresetEnv({
|
|
255
268
|
stage: 0
|
|
256
269
|
}),
|
|
257
|
-
|
|
258
|
-
|
|
270
|
+
cssnano({autoprefixer: false}),
|
|
271
|
+
postcssBrowserReporter
|
|
259
272
|
]
|
|
260
273
|
}
|
|
261
274
|
}
|
|
@@ -291,7 +304,7 @@ module.exports = (webpackEnv, webpackOptions) => {
|
|
|
291
304
|
},
|
|
292
305
|
optimization: (isProduction && isWeb) ? {
|
|
293
306
|
minimizer: [
|
|
294
|
-
new
|
|
307
|
+
new EsbuildPlugin({
|
|
295
308
|
css: true,
|
|
296
309
|
target: targetEnvironment
|
|
297
310
|
})
|
|
@@ -322,15 +335,15 @@ module.exports = (webpackEnv, webpackOptions) => {
|
|
|
322
335
|
alias,
|
|
323
336
|
extensions: ['*', '.mjs', '.js', '.ts', '.tsx', '.jsx', '.json', '.gql', '.graphql'],
|
|
324
337
|
fallback: {
|
|
325
|
-
assert:
|
|
326
|
-
crypto:
|
|
327
|
-
http:
|
|
328
|
-
https:
|
|
329
|
-
os:
|
|
330
|
-
path:
|
|
331
|
-
process:
|
|
332
|
-
stream:
|
|
333
|
-
util:
|
|
338
|
+
assert: relativeNodePath('assert', dirName),
|
|
339
|
+
crypto: relativeNodePath('crypto-browserify', dirName),
|
|
340
|
+
http: relativeNodePath('stream-http', dirName),
|
|
341
|
+
https: relativeNodePath('https-browserify', dirName),
|
|
342
|
+
os: relativeNodePath('os-browserify/browser.js', dirName),
|
|
343
|
+
path: relativeNodePath('path-browserify', dirName),
|
|
344
|
+
process: relativeNodePath('process/browser.js', dirName),
|
|
345
|
+
stream: relativeNodePath('stream-browserify', dirName),
|
|
346
|
+
util: relativeNodePath('util', dirName)
|
|
334
347
|
},
|
|
335
348
|
mainFiles: ['index'],
|
|
336
349
|
modules: [sourceFullPath, 'node_modules'],
|
|
@@ -348,7 +361,7 @@ module.exports = (webpackEnv, webpackOptions) => {
|
|
|
348
361
|
webpack: webpackPath
|
|
349
362
|
};
|
|
350
363
|
webpackConfig.optimization = {minimize: false};
|
|
351
|
-
webpackConfig.entry.wps =
|
|
364
|
+
webpackConfig.entry.wps = relativeNodePath('webpack-plugin-serve/client.js', dirName);
|
|
352
365
|
webpackConfig.stats = {errorDetails: true};
|
|
353
366
|
webpackConfig.plugins.push(
|
|
354
367
|
new WebpackPluginServe({
|
|
@@ -418,7 +431,7 @@ module.exports = (webpackEnv, webpackOptions) => {
|
|
|
418
431
|
// Create site ico files
|
|
419
432
|
const siteLogo = `${sourceFullPath}/images/logo.png`;
|
|
420
433
|
|
|
421
|
-
if(
|
|
434
|
+
if(existsSync(siteLogo)) {
|
|
422
435
|
plugins.push(new FaviconsWebpackPlugin({
|
|
423
436
|
icons: {
|
|
424
437
|
android: true,
|