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

fix(v2): webpack modules resolve should prioritize @docusaurus/core own deps #1907

Merged
merged 3 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- Refactor dark toggle into a hook.
- Changed the way we read the `USE_SSH` env variable during deployment to be the same as in v1.
- Fix accessing `docs/` or `/docs/xxxx` that does not match any existing doc page should return 404 (Not found) page, not blank page.
- Prioritize `@docusaurus/core` dependencies/ node_modules over user's node_modules. This fix a bug whereby if user has core-js@3 on its own node_modules but docusaurus depends on core-js@2, we previously encounter `Module not found: core-js/modules/xxxx` (because core-js@3 doesn't have that).
Another example is if user installed webpack@3 but docusaurus depends on webpack@4.
- Added code block line highlighting feature (thanks @lex111)! If you have previously swizzled the `CodeBlock` theme component, it is recommended to update your source code to have this feature.

## 2.0.0-alpha.31
Expand Down
9 changes: 6 additions & 3 deletions packages/docusaurus/src/webpack/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ export function createBaseConfig(
'@generated': generatedFilesDir,
'@docusaurus': path.resolve(__dirname, '../client/exports'),
},
modules: [
'node_modules',
// This allows you to set a fallback for where Webpack should look for modules.
// We want `@docusaurus/core` own dependencies/`node_modules` to "win" if there is conflict
// Example: if there is core-js@3 in user's own node_modules, but core depends on
// core-js@2, we should use core-js@2.
modules: module.paths.concat([
path.resolve(fs.realpathSync(process.cwd()), 'node_modules'),
],
]),
},
optimization: {
removeAvailableModules: false,
Expand Down