kn-cli 1.0.127 → 1.0.129
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/build/babel.package.json +18 -0
- package/build/babel777.package.json +19 -0
- package/build/package.json +0 -15
- package/build/webpack.config.js +37 -35
- package/package.json +1 -1
- package/src/build.js +7 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"devDependencies": {
|
|
3
|
+
"webpack": "4.43.0",
|
|
4
|
+
"webpack-cli": "3.3.12",
|
|
5
|
+
"webpack-dev-server": "3.11.0",
|
|
6
|
+
"@babel/core": "7.24.0",
|
|
7
|
+
"@babel/preset-env": "7.24.0",
|
|
8
|
+
"@babel/preset-react": "~7.23.3",
|
|
9
|
+
"@babel/plugin-transform-class-properties": "~7.24.0",
|
|
10
|
+
"@babel/plugin-proposal-decorators": "~7.24.0",
|
|
11
|
+
"@babel/plugin-transform-private-methods": "~7.24.0",
|
|
12
|
+
"@babel/plugin-transform-runtime": "7.24.0",
|
|
13
|
+
"@babel/runtime-corejs3": "~7.24.0",
|
|
14
|
+
"@babel/plugin-transform-private-property-in-object": "~7.24.0",
|
|
15
|
+
"babel-loader": "8.3.0",
|
|
16
|
+
"babel-plugin-import": "~1.13.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"devDependencies": {
|
|
3
|
+
"@babel/core": "7.7.7",
|
|
4
|
+
"@babel/plugin-proposal-class-properties": "~7.8.3",
|
|
5
|
+
"@babel/plugin-proposal-decorators": "~7.8.3",
|
|
6
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "~7.8.3",
|
|
7
|
+
"@babel/plugin-proposal-optional-chaining": "~7.8.3",
|
|
8
|
+
"@babel/plugin-proposal-private-methods": "~7.8.3",
|
|
9
|
+
"@babel/plugin-transform-runtime": "7.5.0",
|
|
10
|
+
"@babel/plugin-transform-regenerator": "~7.27.5",
|
|
11
|
+
"@babel/plugin-proposal-logical-assignment-operators": "~7.8.3",
|
|
12
|
+
"@babel/polyfill": "~7.8.7",
|
|
13
|
+
"@babel/preset-env": "7.7.7",
|
|
14
|
+
"@babel/preset-react": "~7.8.3",
|
|
15
|
+
"@babel/runtime-corejs3": "~7.8.4",
|
|
16
|
+
"babel-loader": "~8.0.6",
|
|
17
|
+
"babel-plugin-import": "~1.13.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/build/package.json
CHANGED
|
@@ -13,23 +13,8 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@babel/core": "7.7.7",
|
|
17
|
-
"@babel/plugin-proposal-class-properties": "~7.8.3",
|
|
18
|
-
"@babel/plugin-proposal-decorators": "~7.8.3",
|
|
19
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "~7.8.3",
|
|
20
|
-
"@babel/plugin-proposal-optional-chaining": "~7.8.3",
|
|
21
|
-
"@babel/plugin-proposal-private-methods": "~7.8.3",
|
|
22
|
-
"@babel/plugin-transform-runtime": "7.5.0",
|
|
23
|
-
"@babel/plugin-transform-regenerator": "~7.27.5",
|
|
24
|
-
"@babel/plugin-proposal-logical-assignment-operators": "~7.8.3",
|
|
25
|
-
"@babel/polyfill": "~7.8.7",
|
|
26
|
-
"@babel/preset-env": "7.7.7",
|
|
27
|
-
"@babel/preset-react": "~7.8.3",
|
|
28
|
-
"@babel/runtime-corejs3": "~7.8.4",
|
|
29
16
|
"autoprefixer": "~9.8.8",
|
|
30
17
|
"babel-eslint": "~10.1.0",
|
|
31
|
-
"babel-loader": "~8.0.6",
|
|
32
|
-
"babel-plugin-import": "~1.13.0",
|
|
33
18
|
"browser-sync": "~2.26.7",
|
|
34
19
|
"bundle-loader": "~0.5.2",
|
|
35
20
|
"clean-webpack-plugin": "~3.0.0",
|
package/build/webpack.config.js
CHANGED
|
@@ -86,6 +86,9 @@ apiKeys.map(key=>{
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
let Alias = {};
|
|
89
|
+
if(CLI_CONFIG?.alias){
|
|
90
|
+
Alias = {...Alias,...CLI_CONFIG?.alias}
|
|
91
|
+
}
|
|
89
92
|
// if(devMode){
|
|
90
93
|
// Alias = {
|
|
91
94
|
// 'react-dom$': 'react-dom/profiling',
|
|
@@ -127,7 +130,19 @@ if(!hashMode){
|
|
|
127
130
|
////////////// OUTPUT-END ///////////////
|
|
128
131
|
|
|
129
132
|
/////////////// RULES ////////////////
|
|
133
|
+
const BABEL_PLUGINS=[
|
|
134
|
+
['@babel/plugin-transform-runtime', { corejs: 3 }],
|
|
135
|
+
]
|
|
136
|
+
const BABEL_PLUGINS_777=[
|
|
137
|
+
['@babel/plugin-transform-runtime', { corejs: 3 }],
|
|
138
|
+
'@babel/plugin-proposal-optional-chaining',
|
|
139
|
+
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
140
|
+
['@babel/plugin-proposal-decorators', { legacy: true }],
|
|
141
|
+
['@babel/plugin-proposal-private-methods', { loose: true }],
|
|
142
|
+
['@babel/plugin-proposal-class-properties', { loose: true }],
|
|
143
|
+
['@babel/plugin-proposal-logical-assignment-operators', { loose: true }],
|
|
130
144
|
|
|
145
|
+
]
|
|
131
146
|
const LOADER_JS=[
|
|
132
147
|
{
|
|
133
148
|
loader: 'babel-loader',
|
|
@@ -137,51 +152,38 @@ const LOADER_JS=[
|
|
|
137
152
|
[
|
|
138
153
|
'@babel/preset-env',
|
|
139
154
|
{
|
|
140
|
-
targets:
|
|
141
|
-
? { chrome: '90' }
|
|
142
|
-
: {
|
|
143
|
-
chrome: '40',
|
|
144
|
-
ie: '11',
|
|
145
|
-
},
|
|
155
|
+
targets: { chrome: '40' }
|
|
146
156
|
},
|
|
147
157
|
],
|
|
148
158
|
],
|
|
149
|
-
plugins:
|
|
150
|
-
['@babel/plugin-transform-runtime', { corejs: 3 }],
|
|
151
|
-
'@babel/plugin-proposal-optional-chaining',
|
|
152
|
-
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
153
|
-
['@babel/plugin-proposal-decorators', { legacy: true }],
|
|
154
|
-
['@babel/plugin-proposal-private-methods', { loose: true }],
|
|
155
|
-
['@babel/plugin-proposal-class-properties', { loose: true }],
|
|
156
|
-
['@babel/plugin-proposal-logical-assignment-operators', { loose: true }],
|
|
157
|
-
|
|
158
|
-
// ["import", {
|
|
159
|
-
// style: false,//"css",
|
|
160
|
-
// libraryName: "kn-hooks" ,
|
|
161
|
-
// libraryDirectory:"src",
|
|
162
|
-
// camel2DashComponentName:false,
|
|
163
|
-
// }],
|
|
164
|
-
// ["import", {
|
|
165
|
-
// style: true,//"css",
|
|
166
|
-
// libraryDirectory:"",
|
|
167
|
-
// libraryName: "antd" ,
|
|
168
|
-
// }]
|
|
169
|
-
],
|
|
159
|
+
plugins:BABEL_PLUGINS,
|
|
170
160
|
},
|
|
171
161
|
},
|
|
172
162
|
]
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
163
|
+
|
|
164
|
+
// babel777时需要
|
|
165
|
+
// if(process.env.build_env == 'localdebug'){
|
|
166
|
+
// if(devServer?.hot&&devServer?.reactRefresh==true){
|
|
167
|
+
// LOADER_JS[0].options.plugins.push(['react-refresh/babel'])//
|
|
168
|
+
// LOADER_JS_ES[0].options.plugins.push(['react-refresh/babel'])//
|
|
169
|
+
// }
|
|
170
|
+
// }
|
|
178
171
|
|
|
179
172
|
const rules= [
|
|
180
173
|
{
|
|
181
|
-
test: /\.js[x]?$/,
|
|
174
|
+
test: /\.[m]?js[x]?$/,
|
|
182
175
|
exclude: /node_modules/,
|
|
183
176
|
use: LOADER_JS,
|
|
184
177
|
},
|
|
178
|
+
{
|
|
179
|
+
test: /\.[m]?js[x]?$/,
|
|
180
|
+
include: [
|
|
181
|
+
/node_modules\/antd5/,
|
|
182
|
+
/node_modules\/antd5\/locale/,
|
|
183
|
+
/node_modules\/@rc-component/,
|
|
184
|
+
],
|
|
185
|
+
use:LOADER_JS
|
|
186
|
+
},
|
|
185
187
|
// {
|
|
186
188
|
// test: /\.json$/,
|
|
187
189
|
// use: 'json-loader'
|
|
@@ -289,7 +291,7 @@ if(CLI_CONFIG.rules){
|
|
|
289
291
|
if(CLI_CONFIG.rules.compileNpmPackage){
|
|
290
292
|
let JS_LIST= CLI_CONFIG.rules.compileNpmPackage.join('|');
|
|
291
293
|
rules.push({
|
|
292
|
-
test: /\.js[x]?$/,
|
|
294
|
+
test: /\.[m]?js[x]?$/,
|
|
293
295
|
include: new RegExp(`(${JS_LIST})`),
|
|
294
296
|
use: LOADER_JS
|
|
295
297
|
},)
|
|
@@ -521,9 +523,9 @@ const config={
|
|
|
521
523
|
output: output,
|
|
522
524
|
resolve: {
|
|
523
525
|
modules: [
|
|
526
|
+
'node_modules',
|
|
524
527
|
path.resolve(dirname,'node_modules'),
|
|
525
528
|
path.resolve(webpackPath, 'node_modules'),
|
|
526
|
-
'node_modules',
|
|
527
529
|
],
|
|
528
530
|
extensions: ['.jsx', '.js', '.json','.mjs'],
|
|
529
531
|
alias: {
|
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -54,6 +54,8 @@ module.exports= async (options={})=> {
|
|
|
54
54
|
// 构建模板
|
|
55
55
|
const tempWebpackDir = path.resolve(tempProjectDir,"_webpack");
|
|
56
56
|
const tempWebpackPackagePath = path.resolve(tempWebpackDir,'package.json');
|
|
57
|
+
const tempWebpackBabelPackagePath = path.resolve(tempWebpackDir,'babel.package.json');
|
|
58
|
+
|
|
57
59
|
const tempVitePackagePath = path.resolve(tempWebpackDir,'vite.package.json');
|
|
58
60
|
const tempWebpackConfigPath = path.resolve(tempWebpackDir,'webpack.config.js');
|
|
59
61
|
const tempStartShell = path.resolve(tempWebpackDir,'start.sh');
|
|
@@ -191,17 +193,21 @@ module.exports= async (options={})=> {
|
|
|
191
193
|
task:async (ctx,task)=>{
|
|
192
194
|
return new Promise(resolve=>{
|
|
193
195
|
try{
|
|
196
|
+
let babelPackageJson={
|
|
197
|
+
devDependencies:{}
|
|
198
|
+
};
|
|
194
199
|
task.title='开始构造package'
|
|
195
200
|
projectPackage= require(projectPackagePath);
|
|
196
201
|
if(type == 'dev' && answer?.devTool == 'vite'){
|
|
197
202
|
webpackPackage= require(tempVitePackagePath);
|
|
198
203
|
}else{
|
|
199
204
|
webpackPackage= require(tempWebpackPackagePath);
|
|
205
|
+
babelPackageJson = require(tempWebpackBabelPackagePath);
|
|
200
206
|
}
|
|
201
207
|
|
|
202
208
|
// 将项目文件夹下的package.json内dependencies部分合并入 _webpack/package.json
|
|
203
209
|
webpackPackage.dependencies = {...webpackPackage.dependencies ,...projectPackage.dependencies};
|
|
204
|
-
webpackPackage.devDependencies = {...webpackPackage.devDependencies ,...projectPackage.devDependencies};
|
|
210
|
+
webpackPackage.devDependencies = {...webpackPackage.devDependencies ,...babelPackageJson.devDependencies,...projectPackage.devDependencies};
|
|
205
211
|
webpackPackage.overrides = {...webpackPackage.overrides ,...projectPackage.overrides};
|
|
206
212
|
|
|
207
213
|
|