kn-cli 1.0.137 → 1.0.138

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.
@@ -14,5 +14,6 @@
14
14
  "@babel/plugin-transform-private-property-in-object": "~7.24.0",
15
15
  "babel-loader": "8.3.0",
16
16
  "babel-plugin-import": "~1.13.0"
17
- }
17
+ },
18
+ "babelPlugins": [["@babel/plugin-transform-runtime", { "corejs": 3 }], "@babel/plugin-transform-class-properties"]
18
19
  }
@@ -15,5 +15,14 @@
15
15
  "@babel/runtime-corejs3": "~7.8.4",
16
16
  "babel-loader": "~8.0.6",
17
17
  "babel-plugin-import": "~1.13.0"
18
- }
18
+ },
19
+ "babelPlugins": [
20
+ ["@babel/plugin-transform-runtime", { "corejs": 3 }],
21
+ "@babel/plugin-proposal-optional-chaining",
22
+ "@babel/plugin-proposal-nullish-coalescing-operator",
23
+ ["@babel/plugin-proposal-decorators", { "legacy": true }],
24
+ ["@babel/plugin-proposal-private-methods", { "loose": true }],
25
+ ["@babel/plugin-proposal-class-properties", { "loose": true }],
26
+ ["@babel/plugin-proposal-logical-assignment-operators", { "loose": true }]
27
+ ]
19
28
  }
@@ -1,6 +1,11 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
3
  const log = require('./writeLog.js')()
4
+ const packageJson = require('./package.json');
5
+
6
+ log('==========package.json===========');
7
+ warn(`babelPlugins:${packageJson.babelPlugins}`);
8
+
4
9
  log('==========读取webpack.config.js===========');
5
10
  const webpack = require('webpack');
6
11
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
@@ -132,20 +137,6 @@ if(!hashMode){
132
137
  ////////////// OUTPUT-END ///////////////
133
138
 
134
139
  /////////////// RULES ////////////////
135
- const BABEL_PLUGINS=[
136
- ['@babel/plugin-transform-runtime', { corejs: 3}],
137
- '@babel/plugin-transform-class-properties'
138
- ]
139
- const BABEL_PLUGINS_777=[
140
- ['@babel/plugin-transform-runtime', { corejs: 3 }],
141
- '@babel/plugin-proposal-optional-chaining',
142
- '@babel/plugin-proposal-nullish-coalescing-operator',
143
- ['@babel/plugin-proposal-decorators', { legacy: true }],
144
- ['@babel/plugin-proposal-private-methods', { loose: true }],
145
- ['@babel/plugin-proposal-class-properties', { loose: true }],
146
- ['@babel/plugin-proposal-logical-assignment-operators', { loose: true }],
147
-
148
- ]
149
140
  const LOADER_JS=[
150
141
  {
151
142
  loader: 'babel-loader',
@@ -160,11 +151,26 @@ const LOADER_JS=[
160
151
  },
161
152
  ],
162
153
  ],
163
- plugins:BABEL_PLUGINS,
154
+ plugins:packageJson.babelPlugins,
164
155
  },
165
156
  },
166
157
  ]
167
-
158
+ // 只做babel语法转换,不做module转换和polyfill
159
+ const LOADER_JS_ONLY_BABEL=[
160
+ {
161
+ loader: 'babel-loader',
162
+ options: {
163
+ configFile: false,
164
+ babelrc: false,
165
+ // plugins:packageJson.babelPlugins,
166
+ plugins: [
167
+ '@babel/plugin-transform-optional-chaining',
168
+ '@babel/plugin-transform-nullish-coalescing-operator',
169
+ '@babel/plugin-transform-logical-assignment-operators',
170
+ ],
171
+ },
172
+ }
173
+ ]
168
174
  // babel777时需要
169
175
  // if(process.env.build_env == 'localdebug'){
170
176
  // if(devServer?.hot&&devServer?.reactRefresh==true){
@@ -301,6 +307,18 @@ if(CLI_CONFIG.rules){
301
307
  type: 'javascript/auto',
302
308
  },)
303
309
  }
310
+ if(CLI_CONFIG.rules.compileNpmPackageOnlyBabel){
311
+ let JS_LIST= CLI_CONFIG.rules.compileNpmPackageOnlyBabel.join('|');
312
+ // console.log(`compileNpmPackageOnlyBabel:${JS_LIST}`);
313
+ rules.push({
314
+ test: /\.[m]?js[x]?$/,
315
+ include: new RegExp(`(${JS_LIST})`),
316
+ use: LOADER_JS_ONLY_BABEL,
317
+ type: 'javascript/auto',
318
+ },)
319
+ }
320
+
321
+
304
322
  }
305
323
  ////////////// RULES-END ///////////////
306
324
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-cli",
3
- "version": "1.0.137",
3
+ "version": "1.0.138",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/build.js CHANGED
@@ -209,7 +209,9 @@ module.exports= async (options={})=> {
209
209
  webpackPackage.dependencies = {...webpackPackage.dependencies ,...projectPackage.dependencies};
210
210
  webpackPackage.devDependencies = {...webpackPackage.devDependencies ,...babelPackageJson.devDependencies,...projectPackage.devDependencies};
211
211
  webpackPackage.overrides = {...webpackPackage.overrides ,...projectPackage.overrides};
212
-
212
+ if(babelPackageJson?.babelPlugins){
213
+ webpackPackage.babelPlugins=[...babelPackageJson.babelPlugins];
214
+ }
213
215
 
214
216
  // 将package配置写回_webpack/package.json内
215
217
  jsonfile.writeFile(tempWebpackPackagePath,webpackPackage,{spaces: 2, EOL: '\r\n' },function(err){
@@ -1,6 +1,13 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "ignoreDeprecations":"6.0",
4
+ "noImplicitAny":false,
5
+ "strict": false,
3
6
  "baseUrl": ".",
7
+ "target":"es2015",
8
+ "module": "esnext",
9
+ "moduleResolution": "node", // 👈 明确指定使用 Node 模块解析方式
10
+ "downlevelIteration": true,
4
11
  "emitDecoratorMetadata": true,
5
12
  "experimentalDecorators": true,
6
13
  "lib": ["dom", "ES2021"],
@@ -10,5 +17,13 @@
10
17
  "paths": {
11
18
  "@/*": ["./public/src/*"]
12
19
  },
13
- }
20
+ },
21
+ // 👇 关键:排除掉无关的大型文件夹
22
+ "exclude": [
23
+ "node_modules",
24
+ ],
25
+ "include": [
26
+ "public/src/**/*",
27
+ "global.d.ts" // 别忘了包含你之前创建的声明文件
28
+ ],
14
29
  }