diff --git a/package.json b/package.json index feb592d91..43160a4ef 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "lib:<<<-----": "<<<<<<<<<<<<<<<<<<<<<<<<<<<", "kkt:----->>>": ">>>>>>>>>>>>>>>>>>>>>>>>>>>", "kkt:watch": "lerna exec --scope kkt -- npm run watch", + "kkt:build": "lerna exec --scope kkt -- npm run build", "kkt:test": "lerna exec tsbb test --scope kkt", "kkt:coverage": "lerna exec \"tsbb test --coverage\" --scope kkt", "kkt:<<<-----": "<<<<<<<<<<<<<<<<<<<<<<<<<<<", diff --git a/packages/less-modules/tsconfig.json b/packages/less-modules/tsconfig.json index 18c78a07e..643b654be 100644 --- a/packages/less-modules/tsconfig.json +++ b/packages/less-modules/tsconfig.json @@ -1,16 +1,16 @@ { "compilerOptions": { - "module": "commonjs", + "module": "Node16", + "target": "ES2022", + "strict": true, + "declaration": true, "esModuleInterop": true, + "resolveJsonModule": true, + "moduleResolution": "node16", "skipLibCheck": true, - "declaration": true, - "target": "es2017", "noImplicitAny": true, - "resolveJsonModule": true, - "moduleResolution": "node", - "sourceMap": true, "outDir": "lib", - "baseUrl": "./" + "baseUrl": "." }, - "include": ["src"] + "include": ["src/**/*"] } diff --git a/packages/raw-modules/tsconfig.json b/packages/raw-modules/tsconfig.json index c74067fc7..643b654be 100644 --- a/packages/raw-modules/tsconfig.json +++ b/packages/raw-modules/tsconfig.json @@ -1,16 +1,16 @@ { "compilerOptions": { - "module": "commonjs", + "module": "Node16", + "target": "ES2022", + "strict": true, + "declaration": true, "esModuleInterop": true, + "resolveJsonModule": true, + "moduleResolution": "node16", "skipLibCheck": true, - "declaration": true, - "target": "es2017", "noImplicitAny": true, - "resolveJsonModule": true, - "moduleResolution": "node", - "sourceMap": true, "outDir": "lib", - "baseUrl": "./" + "baseUrl": "." }, "include": ["src/**/*"] } diff --git a/packages/react-library/src/index.ts b/packages/react-library/src/index.ts index 6e52bcd40..3d76815e6 100644 --- a/packages/react-library/src/index.ts +++ b/packages/react-library/src/index.ts @@ -88,7 +88,9 @@ export default (conf: Configuration, env: string, options = {} as ReactLibraryOp fileName = minfilename[0] || libraryName; minfilename.splice(1, 0, 'min'); - conf.entry = path.resolve(entryFile); + if (entryFile) { + conf.entry = path.resolve(entryFile); + } conf.devtool = false; conf.output = { // commonjs @@ -105,10 +107,10 @@ export default (conf: Configuration, env: string, options = {} as ReactLibraryOp */ const regexp = /(MiniCssExtractPlugin)/; conf.plugins = conf.plugins - .map((item) => { - if (item.constructor && item.constructor.name && !regexp.test(item.constructor.name)) { + ?.map((item) => { + if (item && item.constructor && item.constructor.name && !regexp.test(item.constructor.name)) { return null; - } else if (regexp.test(item.constructor.name)) { + } else if (item && regexp.test(item.constructor.name)) { return new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output // both options are optional @@ -126,7 +128,7 @@ export default (conf: Configuration, env: string, options = {} as ReactLibraryOp minimizer: [], }; } else { - conf.plugins.push(new CssMinimizerPlugin({ ...options.cssMinimizerPluginOptions })); + conf.plugins?.push(new CssMinimizerPlugin({ ...options.cssMinimizerPluginOptions })); conf.optimization!.minimizer!.push( new TerserPlugin({ // cache: true, @@ -139,8 +141,8 @@ export default (conf: Configuration, env: string, options = {} as ReactLibraryOp }), ); conf.output.filename = minfilename.join('.'); - delete conf.optimization.runtimeChunk; - delete conf.optimization.splitChunks; + delete conf.optimization?.runtimeChunk; + delete conf.optimization?.splitChunks; } } return conf; diff --git a/packages/react-library/tsconfig.json b/packages/react-library/tsconfig.json index c74067fc7..643b654be 100644 --- a/packages/react-library/tsconfig.json +++ b/packages/react-library/tsconfig.json @@ -1,16 +1,16 @@ { "compilerOptions": { - "module": "commonjs", + "module": "Node16", + "target": "ES2022", + "strict": true, + "declaration": true, "esModuleInterop": true, + "resolveJsonModule": true, + "moduleResolution": "node16", "skipLibCheck": true, - "declaration": true, - "target": "es2017", "noImplicitAny": true, - "resolveJsonModule": true, - "moduleResolution": "node", - "sourceMap": true, "outDir": "lib", - "baseUrl": "./" + "baseUrl": "." }, "include": ["src/**/*"] } diff --git a/packages/resolve-fallback/src/index.ts b/packages/resolve-fallback/src/index.ts index abae22167..a27e4c4d6 100644 --- a/packages/resolve-fallback/src/index.ts +++ b/packages/resolve-fallback/src/index.ts @@ -4,7 +4,7 @@ export default function resolveFallback(conf: Configuration): Configuration { if (!conf) { throw Error('KKT:@kkt/resolve-fallback: there is no config found'); } - conf.resolve.fallback = Object.assign(conf.resolve.fallback || {}, { + conf.resolve!.fallback = Object.assign(conf.resolve?.fallback || {}, { assert: require.resolve('assert'), buffer: require.resolve('buffer'), fs: false, @@ -16,7 +16,7 @@ export default function resolveFallback(conf: Configuration): Configuration { stream: require.resolve('stream-browserify'), url: require.resolve('url'), }); - conf.module.rules.unshift({ + conf.module?.rules?.unshift({ test: /\.m?js$/, resolve: { fullySpecified: false, // disable the behavior diff --git a/packages/resolve-fallback/tsconfig.json b/packages/resolve-fallback/tsconfig.json index 18c78a07e..643b654be 100644 --- a/packages/resolve-fallback/tsconfig.json +++ b/packages/resolve-fallback/tsconfig.json @@ -1,16 +1,16 @@ { "compilerOptions": { - "module": "commonjs", + "module": "Node16", + "target": "ES2022", + "strict": true, + "declaration": true, "esModuleInterop": true, + "resolveJsonModule": true, + "moduleResolution": "node16", "skipLibCheck": true, - "declaration": true, - "target": "es2017", "noImplicitAny": true, - "resolveJsonModule": true, - "moduleResolution": "node", - "sourceMap": true, "outDir": "lib", - "baseUrl": "./" + "baseUrl": "." }, - "include": ["src"] + "include": ["src/**/*"] } diff --git a/packages/scope-plugin-options/src/index.ts b/packages/scope-plugin-options/src/index.ts index fa52c3390..884bfa1b3 100644 --- a/packages/scope-plugin-options/src/index.ts +++ b/packages/scope-plugin-options/src/index.ts @@ -10,9 +10,9 @@ export type ReactLibraryOptions = LoaderConfOptions & { const regexp = /(ModuleScopePlugin)/; export function disableScopePlugin(conf: Configuration) { - conf.resolve.plugins = conf.resolve.plugins - .map((plugin) => { - if (plugin.constructor && plugin.constructor.name && regexp.test(plugin.constructor.name)) { + conf.resolve!.plugins = conf.resolve?.plugins + ?.map((plugin) => { + if (plugin && plugin.constructor && plugin.constructor.name && regexp.test(plugin.constructor.name)) { return undefined; } return plugin; @@ -31,8 +31,8 @@ export default function scopePluginOptions( } const { allowedFiles, appSrcs, allowedPaths } = options || {}; - const moduleScopePlugin = conf.resolve.plugins.find( - (plugin) => plugin.constructor && plugin.constructor.name && regexp.test(plugin.constructor.name), + const moduleScopePlugin = conf.resolve?.plugins?.find( + (plugin) => plugin?.constructor && plugin.constructor.name && regexp.test(plugin.constructor.name), ); if (moduleScopePlugin && typeof moduleScopePlugin === 'object') { if (allowedFiles && Array.isArray(allowedFiles)) { diff --git a/packages/scope-plugin-options/tsconfig.json b/packages/scope-plugin-options/tsconfig.json index 18c78a07e..643b654be 100644 --- a/packages/scope-plugin-options/tsconfig.json +++ b/packages/scope-plugin-options/tsconfig.json @@ -1,16 +1,16 @@ { "compilerOptions": { - "module": "commonjs", + "module": "Node16", + "target": "ES2022", + "strict": true, + "declaration": true, "esModuleInterop": true, + "resolveJsonModule": true, + "moduleResolution": "node16", "skipLibCheck": true, - "declaration": true, - "target": "es2017", "noImplicitAny": true, - "resolveJsonModule": true, - "moduleResolution": "node", - "sourceMap": true, "outDir": "lib", - "baseUrl": "./" + "baseUrl": "." }, - "include": ["src"] + "include": ["src/**/*"] } diff --git a/packages/stylus-modules/src/index.ts b/packages/stylus-modules/src/index.ts index 2740de71e..b9213a7b5 100644 --- a/packages/stylus-modules/src/index.ts +++ b/packages/stylus-modules/src/index.ts @@ -158,9 +158,9 @@ const createStylusModule = (stylusLoaderOptions = {} as StylusLoaderOptions) => }); // Exclude all less files (including module files) from file-loader - conf.module.rules = conf.module.rules.map((rule) => { - if (typeof rule === 'object' && rule.oneOf) { - loaders.forEach((item) => rule.oneOf.splice(rule.oneOf.length - 1, 0, item)); + conf.module!.rules = conf.module?.rules?.map((rule) => { + if (rule && typeof rule === 'object' && rule.oneOf) { + loaders.forEach((item) => rule.oneOf?.splice(rule.oneOf.length - 1, 0, item)); } return rule; }); diff --git a/packages/stylus-modules/tsconfig.json b/packages/stylus-modules/tsconfig.json index 18c78a07e..643b654be 100644 --- a/packages/stylus-modules/tsconfig.json +++ b/packages/stylus-modules/tsconfig.json @@ -1,16 +1,16 @@ { "compilerOptions": { - "module": "commonjs", + "module": "Node16", + "target": "ES2022", + "strict": true, + "declaration": true, "esModuleInterop": true, + "resolveJsonModule": true, + "moduleResolution": "node16", "skipLibCheck": true, - "declaration": true, - "target": "es2017", "noImplicitAny": true, - "resolveJsonModule": true, - "moduleResolution": "node", - "sourceMap": true, "outDir": "lib", - "baseUrl": "./" + "baseUrl": "." }, - "include": ["src"] + "include": ["src/**/*"] }