Skip to content

Can't resolve 'component-controls-bundle #34

Description

@alesoto13

Using craco in a create-react-app project I'm getting the following error

Failed to compile.
./node_modules/@component-controls/base-integration/dist/store.js
Module not found: Can't resolve 'component-controls-bundle' in '/mnt/c/wsl/audience/client/node_modules/@component-controls/base-integration/dist'

My craco config file

const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const path = require('path')
const fs = require('fs')
const CracoLessPlugin = require('craco-less')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')

const sharedFiles = fs.readdirSync(path.resolve(__dirname, '..', 'shared'))

const {
  withComponentControls
} = require('@component-controls/react-router-integration/webpack-build')

const publicFolder = process.env.PUBLIC_PATH || 'public'
const publicPath = path.join(__dirname, publicFolder)
const distFolder = process.env.BUILD_PATH || 'build'
const distPath = path.join(__dirname, distFolder)

process.env.REACT_APP_ENV = process.env.NODE_ENV || 'development'
process.env.PUBLIC_URL = '/'

const config = {
  devServer: {
    contentBase: publicPath,
    historyApiFallback: true,
    open: true,
    hot: true
  },
  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            modifyVars: { '@primary-color': '#97d700' },
            javascriptEnabled: true
          }
        }
      }
    }
  ],
  webpack: {
    plugins: {
      add: [
        new HtmlWebpackPlugin({
          template: 'public/index.html'
        }),
        new webpack.HotModuleReplacementPlugin()
      ]
    },
    configure: (webpackConfig) => {
      if (process.env.RUN_ANALYZER) {
        webpackConfig.plugins.push(new BundleAnalyzerPlugin())
      }

      webpackConfig.devtool = 'inline-source-map'

      // Remove multiple different bn.js in bundle
      webpackConfig.resolve.alias['bn.js'] = path.resolve(
        __dirname,
        'node_modules/bn.js'
      )

      webpackConfig.output = {
        path: distPath,
        publicPath: '/',
        jsonpFunction: 'wpJson'
      }

      webpackConfig.entry = './src/index.js'

      webpackConfig.resolve.extensions = ['.js']

      return webpackConfig
    }
  }
}

module.exports = withComponentControls({
  config,
  options: { configPath: '.config', distFolder: publicFolder }
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions