Skip to content

Commit

Permalink
type: fix type error & modify ts config.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 14, 2023
1 parent 812f186 commit 2d8a488
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 63 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:<<<-----": "<<<<<<<<<<<<<<<<<<<<<<<<<<<",
Expand Down
16 changes: 8 additions & 8 deletions packages/less-modules/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}
14 changes: 7 additions & 7 deletions packages/raw-modules/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}
16 changes: 9 additions & 7 deletions packages/react-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions packages/react-library/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}
4 changes: 2 additions & 2 deletions packages/resolve-fallback/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions packages/resolve-fallback/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}
10 changes: 5 additions & 5 deletions packages/scope-plugin-options/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down
16 changes: 8 additions & 8 deletions packages/scope-plugin-options/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}
6 changes: 3 additions & 3 deletions packages/stylus-modules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
16 changes: 8 additions & 8 deletions packages/stylus-modules/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}

0 comments on commit 2d8a488

Please sign in to comment.