Skip to content

Fix loader concatentation bug#173

Merged
arunoda merged 1 commit intostorybookjs:masterfrom
stefvhuynh:master
May 9, 2016
Merged

Fix loader concatentation bug#173
arunoda merged 1 commit intostorybookjs:masterfrom
stefvhuynh:master

Conversation

@stefvhuynh
Copy link
Copy Markdown
Contributor

This has to do with using custom webpack.config.js files. The code tries to add customConfig.module.loaders. And if customConfig.module is not defined, there is an error.

@stefvhuynh stefvhuynh closed this May 6, 2016
@stefvhuynh stefvhuynh reopened this May 6, 2016
@arunoda
Copy link
Copy Markdown
Member

arunoda commented May 6, 2016

I need more information. I can't see what this solves anything. This change seems to have no effect on anything.

Am I wrong?

@stefvhuynh
Copy link
Copy Markdown
Contributor Author

If I have a custom webpack config that looks like this, it'll break:

module.exports = {
  resolves: { extensions: [".jsx"] }
}

I can fix it, by changing it to this:

module.exports = {
  resolves: { extensions: [".jsx"] },
  module: {}
}

Take a look at these lines: https://github.com/kadirahq/react-storybook/blob/master/src/server/config.js#L90-L93

If customConfig.module does not exist, it uses {}. However, on line 93, it expects customConfig.module to be defined (to access customConfig.module.loaders).

@arunoda
Copy link
Copy Markdown
Member

arunoda commented May 6, 2016

Okay. I got it.
Then the PR should be something like this:

return {
    ...customConfig,
    // We'll always load our configurations after the custom config.
    // So, we'll always load the stuff we need.
    ...config,
    // We need to use our and custom plugins.
    plugins: [
      ...config.plugins,
      ...customConfig.plugins || [],
    ],
    module: {
      ...config.module,
      // We need to use our and custom loaders.
      ...customConfig.module || {},
      loaders: [
        ...config.module.loaders,
        ...customConfig.module? customConfig.module.loaders || [] : {},
      ],
    },
  };

Isn't it?

@stefvhuynh
Copy link
Copy Markdown
Contributor Author

stefvhuynh commented May 6, 2016

I think instead of {}, you want [] for the second part of the ternary. But whichever way you prefer is how I'll do it (with the ternary or by defining customConfig.module like I did).

@arunoda
Copy link
Copy Markdown
Member

arunoda commented May 9, 2016

@stefvhuynh Your PR sounds great. I'll do a release within today.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Dec 11, 2024

View your CI Pipeline Execution ↗ for commit 01f687d

Command Status Duration Result
nx run-many --target=prep --all --parallel=8 --... ✅ Succeeded 6m 40s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-18 19:50:14 UTC

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

Successfully merging this pull request may close these issues.

3 participants