kn-cli 1.0.128 → 1.0.130

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.
@@ -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
+ }
@@ -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",
@@ -51,6 +51,7 @@ const appVersion= CLI_CONFIG?.version ?? '';
51
51
  const devServer=CLI_CONFIG?.devServer??{};
52
52
  const prject_name = CLI_CONFIG?.name??'';
53
53
  const sourceMapLocal = CLI_CONFIG?.sourcemap?.local??false;//是否将soucemap改为本地
54
+ const resolveModules=CLI_CONFIG?.resolve?.modules??[];
54
55
 
55
56
  warn(`=====================env-webpack=========================`);
56
57
  warn(`devMode:${devMode}`);
@@ -86,6 +87,9 @@ apiKeys.map(key=>{
86
87
  });
87
88
 
88
89
  let Alias = {};
90
+ if(CLI_CONFIG?.alias){
91
+ Alias = {...Alias,...CLI_CONFIG?.alias}
92
+ }
89
93
  // if(devMode){
90
94
  // Alias = {
91
95
  // 'react-dom$': 'react-dom/profiling',
@@ -127,7 +131,19 @@ if(!hashMode){
127
131
  ////////////// OUTPUT-END ///////////////
128
132
 
129
133
  /////////////// RULES ////////////////
134
+ const BABEL_PLUGINS=[
135
+ ['@babel/plugin-transform-runtime', { corejs: 3 }],
136
+ ]
137
+ const BABEL_PLUGINS_777=[
138
+ ['@babel/plugin-transform-runtime', { corejs: 3 }],
139
+ '@babel/plugin-proposal-optional-chaining',
140
+ '@babel/plugin-proposal-nullish-coalescing-operator',
141
+ ['@babel/plugin-proposal-decorators', { legacy: true }],
142
+ ['@babel/plugin-proposal-private-methods', { loose: true }],
143
+ ['@babel/plugin-proposal-class-properties', { loose: true }],
144
+ ['@babel/plugin-proposal-logical-assignment-operators', { loose: true }],
130
145
 
146
+ ]
131
147
  const LOADER_JS=[
132
148
  {
133
149
  loader: 'babel-loader',
@@ -137,44 +153,22 @@ const LOADER_JS=[
137
153
  [
138
154
  '@babel/preset-env',
139
155
  {
140
- targets: devMode
141
- ? { chrome: '90' }
142
- : {
143
- chrome: '40',
144
- ie: '11',
145
- },
156
+ targets: { chrome: '40' }
146
157
  },
147
158
  ],
148
159
  ],
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
- ],
160
+ plugins:BABEL_PLUGINS,
170
161
  },
171
162
  },
172
163
  ]
173
- if(process.env.build_env == 'localdebug'){
174
- if(devServer?.hot&&devServer?.reactRefresh==true){
175
- LOADER_JS[0].options.plugins.push(['react-refresh/babel'])//
176
- }
177
- }
164
+
165
+ // babel777时需要
166
+ // if(process.env.build_env == 'localdebug'){
167
+ // if(devServer?.hot&&devServer?.reactRefresh==true){
168
+ // LOADER_JS[0].options.plugins.push(['react-refresh/babel'])//
169
+ // LOADER_JS_ES[0].options.plugins.push(['react-refresh/babel'])//
170
+ // }
171
+ // }
178
172
 
179
173
  const rules= [
180
174
  {
@@ -182,6 +176,15 @@ const rules= [
182
176
  exclude: /node_modules/,
183
177
  use: LOADER_JS,
184
178
  },
179
+ {
180
+ test: /\.[m]?js[x]?$/,
181
+ include: [
182
+ /node_modules\/antd5/,
183
+ /node_modules\/antd5\/locale/,
184
+ /node_modules\/@rc-component/,
185
+ ],
186
+ use:LOADER_JS
187
+ },
185
188
  // {
186
189
  // test: /\.json$/,
187
190
  // use: 'json-loader'
@@ -521,9 +524,11 @@ const config={
521
524
  output: output,
522
525
  resolve: {
523
526
  modules: [
524
- 'node_modules',
527
+ ...resolveModules,
528
+ // 1. 强制只找当前项目根目录下的 node_modules,不往上爬
525
529
  path.resolve(dirname,'node_modules'),
526
530
  path.resolve(webpackPath, 'node_modules'),
531
+ // 'node_modules'
527
532
  ],
528
533
  extensions: ['.jsx', '.js', '.json','.mjs'],
529
534
  alias: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-cli",
3
- "version": "1.0.128",
3
+ "version": "1.0.130",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
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