0

Want to run app, but get the following error:

enter image description here

This is my project structure:

enter image description here

this is my app module i use export and also export default are same: app component and the imports of the module: enter image description here

My webpack :

const devSever = (isDev) => !isDev ? {} : {
  devServer: {
      open: true,
      hot: true,
      port: 7070,
      contentBase: path.join(__dirname,'public')
     }
};

 const esLintPlugin = (isDev) => isDev ? [] : [new ESLintPlugin({ extensions: ['.ts', '.tsx ','.js']}) ]

module.exports = ({develop}) => ( {
  mode: develop ? 'development': 'production',
  devtool: develop ? 'inline-source-map' : false,
  entry:{ 
    app: './src/index.tsx',
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js',
    assetModuleFilename: 'assets/[hash][ext]' //may be hash
  },
  module: {
    rules: [
      {
        test: /\.(ts|tsx|js)$/,
        use: 'ts-loader',
        exclude: /node_modules/
      },
      {
        test: /\.(?:ico|gif|png|jpg|jpeg|svg)$/i,
        type: 'asset/resource'
      },
      {
        test: /\.(woff(2)?|eot|ttf|otf)$/i,
        type: 'asset/resource'
      },
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader,'css-loader'] 
      }

    ]
  },
  resolve: {
    extensions: ['.tsx','.ts','.js']
  },
  plugins: [
    new CircularDependencyPlugin({
      exclude: /a\.js|node_modules/,
      include: /dir/,
      failOnError: true,
      allowAsyncCycles: false,
      cwd: process.cwd()
    }),
    new HtmlWebpackPlugin({
      template: './src/index.html'
    }),
    new MiniCssExtractPlugin({
      filename: 'style.css'
    }),
    new CopyPlugin({
      patterns: [{from: './public' }]
    }),
    new CleanWebpackPlugin({cleanStaleWebpackAssets: false}),
     ...esLintPlugin(develop)
  ],
  ...devSever(develop)
}); 

it's all work good only if there are not imports and if i write code only in one component

3
  • 3
    Show your app.tsx component. Commented Jul 1, 2021 at 10:52
  • @zhulien added check pls Commented Jul 1, 2021 at 11:42
  • try some of these answers. Commented Jul 1, 2021 at 18:30

1 Answer 1

0

you check out tsconfig.json

{
  "include": ["src/**/*"],
  "compilerOptions": {
    "rootDir": "./src"
  }
}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.