Open FCDave opened 2 years ago
I have similar issues: Webpack / Typescript and AJV as dependecy. building fails these are the errors:
ERROR in [redacted]/node_modules/ajv/lib/compile/codegen/code.ts
52:4-89
[tsl] ERROR in [redacted]/node_modules/ajv/lib/compile/codegen/code.ts(52,5)
TS2322: Type 'CodeItem' is not assignable to type 'string'.
Type 'null' is not assignable to type 'string'.
ERROR in [redacted]/node_modules/ajv/lib/compile/codegen/code.ts
52:12-21
[tsl] ERROR in [redacted]/node_modules/ajv/lib/compile/codegen/code.ts(52,13)
TS2322: Type 'CodeItem' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.
ERROR in [redacted]/node_modules/ajv/lib/compile/resolve.ts
102:2-10
[tsl] ERROR in [redacted]node_modules/ajv/lib/compile/resolve.ts(102,3)
TS2349: This expression is not callable.
Type '{ default: { (schema: SchemaObject, opts: Options, cb?: Callback | undefined): void; (schema: SchemaObject, cb: Callback): void; }; }' has no call signatures.
ERROR in [redacted]/node_modules/ajv/lib/compile/resolve.ts
143:31-36
[tsl] ERROR in [redacted]/node_modules/ajv/lib/compile/resolve.ts(143,32)
TS2349: This expression is not callable.
Type '{ default: (a: any, b: any) => boolean; }' has no call signatures.
4 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.84.1 compiled with 4 errors in 19928 ms
My Webpack file:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'production',
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
devtool: 'inline-source-map',
optimization: {
minimize: true,
mergeDuplicateChunks: false,
removeAvailableModules: true
},
devServer: {
watchFiles: ['src/**/*'],
// ignore public folder
static: {
directory: path.join(__dirname, 'public'),
publicPath: '/',
watch: true,
},
client: {
overlay: false,
}
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './index.html'), // path to your index.html file
})
],
stats: {
warningsFilter: /node_modules/
},
};
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "es2022",
// commonjs, esnext
"lib": [
"esnext",
"dom"
],
"sourceMap": true,
"outDir": "./dist/",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": false,
"strictNullChecks": true,
"moduleResolution": "node",
"skipLibCheck": false,
"resolveJsonModule": true
},
"include": [
"src"
],
// Only include .ts/.tsx files in the src directory
"exclude": [
"node_modules"
]
// Exclude all files in node_modules
}
I am on Debian 12
This issue specifically pertains to bundling my app using webpack where AJV is a dependency on the storybook addon. When performing this I am getting the following errors. My guess is something to do with the setup of my app, some sort of transpiling issue... but I am unsure at this point. I have logged a bug with the maintainer of storybook-addon-headless also.
Steps to reproduce the behavior:
Expected behavior Project gets bundled without issue and dependencies are handled correctly, and serves up the bundle.
Screenshots / Bundle output
webpack.dev.js
webpack.common.js
OS: iOS 11.6.2 (Big Sur) Browser: Chrome Version: 97.0.4692.99 (Official Build) (arm64)
Additional context Webpack 5.66.0 storybook-addon-headless 2.1.3 typescript 4.5.4 ts-loader 9.2.6 storybook-react 6.4.19