Describe the bug
Using both this package in addition to craco-esbuild to build yields an invalid schema that gets passed to webpack.
To Reproduce
Yes - pasted a working craco.config.ts to reproduce the issue.
Expected behavior
I'd expect the time analytics rules to not clobber the esbuild rules, but I'm not entirely sure if that's correct?
Screenshots
package.json
{
"devDependencies": {
"@craco/craco": "^7.1.0",
"@craco/types": "^7.1.0",
"time-analytics-webpack-plugin": "^0.1.20",
"craco-esbuild": "^0.5.2",
}
craco.config.ts
import type { CracoConfig, CracoWebpackConfig } from "@craco/types";
import { TimeAnalyticsPlugin } from 'time-analytics-webpack-plugin';
const CracoEsbuildPlugin = require('craco-esbuild');
const config = {
eslint: {
enable: false,
},
plugins: [
{
plugin: CracoEsbuildPlugin,
},
],
webpack: {
configure: (webpackConfig) => {
const foo = TimeAnalyticsPlugin.wrap({
devtool: "source-map",
ignoreWarnings: [/Failed to parse source map.*wry/],
...webpackConfig,
});
// this will console log below
console.log((webpackConfig.module as any).rules[1])
console.log("result", (foo.module as any).rules[1])
return foo;
}
} as CracoWebpackConfig,
} satisfies CracoConfig;
export default config;
> craco build
# first console log
{
oneOf: [
{
test: [Array],
type: 'asset',
mimetype: 'image/avif',
parser: [Object]
},
{ test: [Array], type: 'asset', parser: [Object] },
{ test: /\.svg$/, use: [Array], issuer: [Object] },
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: '/Users/project/src',
use: [Array]
},
{
test: /\.(js|mjs)$/,
exclude: /@babel(?:\/|\\{1,2})runtime/,
use: [Array]
},
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: [Array],
sideEffects: true
},
{ test: /\.module\.css$/, use: [Array] },
{
test: /\.(scss|sass)$/,
exclude: /\.module\.(scss|sass)$/,
use: [Array],
sideEffects: true
},
{ test: /\.module\.(scss|sass)$/, use: [Array] },
{ exclude: [Array], type: 'asset/resource' }
]
}
# second console log
result {
oneOf: [
{
test: [Array],
type: 'asset',
mimetype: 'image/avif',
parser: [Object]
},
{ test: [Array], type: 'asset', parser: [Object] },
{ test: /\.svg$/, use: [Array], issuer: [Object] },
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: '/Users/project/src',
use: [Array]
},
{
test: /\.(js|mjs)$/,
exclude: /@babel(?:\/|\\{1,2})runtime/,
use: [Array]
},
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: [Array],
sideEffects: true
},
{ test: /\.module\.css$/, use: [Array] },
{
test: /\.(scss|sass)$/,
exclude: /\.module\.(scss|sass)$/,
use: [Array],
sideEffects: true
},
{ test: /\.module\.(scss|sass)$/, use: [Array] },
{ exclude: [Array], type: 'asset/resource' }
]
}
Creating an optimized production build...
Failed to compile.
Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[1] should be one of these:
["..." | object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }, ...]
-> A rule.
Details:
* configuration.module.rules[1].oneOf[3].use[1] has an unknown property 'test'. These properties are valid:
object { ident?, loader?, options? }
* configuration.module.rules[1].oneOf[3].use[1] has an unknown property 'include'. These properties are valid:
object { ident?, loader?, options? }
Additional context
I am sad
Describe the bug
Using both this package in addition to craco-esbuild to build yields an invalid schema that gets passed to webpack.
To Reproduce
Yes - pasted a working craco.config.ts to reproduce the issue.
Expected behavior
I'd expect the time analytics rules to not clobber the esbuild rules, but I'm not entirely sure if that's correct?
Screenshots
package.json
{ "devDependencies": { "@craco/craco": "^7.1.0", "@craco/types": "^7.1.0", "time-analytics-webpack-plugin": "^0.1.20", "craco-esbuild": "^0.5.2", }craco.config.ts
Additional context
I am sad