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

sharetribe-scripts v6.0 and GENERATE_SOURCEMAP=false #1543

Closed
anh-dinh-jh opened this issue Aug 8, 2022 · 3 comments
Closed

sharetribe-scripts v6.0 and GENERATE_SOURCEMAP=false #1543

anh-dinh-jh opened this issue Aug 8, 2022 · 3 comments

Comments

@anh-dinh-jh
Copy link
Contributor

anh-dinh-jh commented Aug 8, 2022

Describe the bug

On the new templates using sharetribe-scripts v6.0, set GENERATE_SOURCEMAP = false, got an error:

create-react-app config structure changed, please check webpack.config.js and update to use the changed config

To Reproduce Steps to reproduce the behavior:

  1. Set GENERATE_SOURCEMAP = false
  2. Run command yarn dev or yarn build
  3. See error

Expected behavior

No errors

Reasons

sharetribe-scripts v6.0:

File: packages/react-scripts/config/sharetribeWebpackConfig.js

hasRules is false, which causes the configStructureKnown is false and then throws an error.

  const hasRules =
      config &&
      config.module &&
      config.module.rules &&
      config.module.rules.length === 2;
    
  ...

  const configStructureKnown = hasRules
        && hasOneOf
        && hasCssLoader
        && hasPlugins
        && hasOutput
        && hasOptimization;

  if (!configStructureKnown) {
    throw new Error(
      'create-react-app config structure changed, please check webpack.config.js and update to use the changed config'
    );
  }

Changes on FB react-scripts
PR: This
react-scripts PR: This

File: packages/react-scripts/config/webpack.config.js
Changes:

[
  // Handle node_modules packages that contain sourcemaps
  shouldUseSourceMap && {
    enforce: 'pre',
    exclude: /@babel(?:\/|\\{1,2})runtime/,
    test: /\.(js|mjs|jsx|ts|tsx|css)$/,
    loader: require.resolve('source-map-loader'),
  },
  ...
].filter(Boolean)

With this change: GENERATE_SOURCEMAP = false --> shouldUseSourceMap is false --> config.module.rules.length is 1 --> config.module.rules.length===2 is false --> configStructureKnown is false and then throws an error.

@Gnito
Copy link
Contributor

Gnito commented Aug 23, 2022

@anh-dinh-jh thanks for reporting this. As mentioned in the other issue, we have had a vacation season, which caused some lag in responses on our part.

The configStructureKnown is now refactored to better work with environment variables (like GENERATE_SOURCEMAP) that affect the config structure.

The fix is not yet fully released, but here's a candidate:
sharetribe/create-react-app#25

@Gnito
Copy link
Contributor

Gnito commented Aug 29, 2022

Now the sharetribe-scripts v6.0.1 is released and taken into use on the master branch of FTW-daily.

@Gnito
Copy link
Contributor

Gnito commented Aug 30, 2022

A new release is made with the updated sharetribe-scripts.
I'm closing this issue.

@Gnito Gnito closed this as completed Aug 30, 2022
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