Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
asotoglez opened this issue Oct 6, 2021 · 1 comment
Open

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

asotoglez opened this issue Oct 6, 2021 · 1 comment

Comments

@asotoglez
Copy link

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 }
})
@atanasster
Copy link
Collaborator

Thank you very much for the issue, i will look into it asap. Do you happen to have a repo that i can use to reproduce?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants