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

Module resolution improvements #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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: 1 addition & 1 deletion .github/workflows/v2-tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- ab/module-resolution
pull_request:
branches:
- master
Expand Down Expand Up @@ -65,7 +66,6 @@ jobs:
run: |
cd test-website
yarn set version berry
yarn config set pnpMode loose
yarn config set npmRegistryServer http://localhost:4873
yarn config set unsafeHttpWhitelist --json '["localhost"]'
yarn config set enableGlobalCache true
Expand Down
2 changes: 1 addition & 1 deletion examples/bootstrap/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@docusaurus/types').DocusaurusConfig} */
/** @type {import('@docusaurus/core/lib').DocusaurusConfig} */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the problem due to not having @docusaurus/types in deps?

Copy link
Owner Author

@cspotcode cspotcode May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so resolving @docusaurus/types will fail in e.g. yarn2 PnP, and it may fail with a node_modules directory depending on how the package manager chooses to set it up. The package manager isn't required to hoist in a particular way, or at all. It is only required to respect each package.json's declared dependencies.

module.exports = {
title: 'My Site',
tagline: 'The tagline of my site',
Expand Down
2 changes: 1 addition & 1 deletion examples/classic/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@docusaurus/types').DocusaurusConfig} */
/** @type {import('@docusaurus/core/lib').DocusaurusConfig} */
module.exports = {
title: 'My Site',
tagline: 'Dinosaurs are cool',
Expand Down
2 changes: 1 addition & 1 deletion examples/facebook/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @format
*/

/** @type {import('@docusaurus/types').DocusaurusConfig} */
/** @type {import('@docusaurus/core/lib').DocusaurusConfig} */
module.exports = {
title: 'My Site',
tagline: 'The tagline of my site',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@docusaurus/types').DocusaurusConfig} */
/** @type {import('@docusaurus/core/lib').DocusaurusConfig} */
module.exports = {
title: 'My Site',
tagline: 'The tagline of my site',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@docusaurus/types').DocusaurusConfig} */
/** @type {import('@docusaurus/core/lib').DocusaurusConfig} */
module.exports = {
title: 'My Site',
tagline: 'Dinosaurs are cool',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @format
*/

/** @type {import('@docusaurus/types').DocusaurusConfig} */
/** @type {import('@docusaurus/core/lib').DocusaurusConfig} */
module.exports = {
title: 'My Site',
tagline: 'The tagline of my site',
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"terser-webpack-plugin": "^5.1.1",
"tslib": "^2.1.0",
"update-notifier": "^5.1.0",
"url": "^0.11.0",
"url-loader": "^4.1.1",
"wait-on": "^5.2.1",
"webpack": "^5.28.0",
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export {default as serve} from './commands/serve';
export {default as clear} from './commands/clear';
export {default as writeTranslations} from './commands/writeTranslations';
export {default as writeHeadingIds} from './commands/writeHeadingIds';
export type {DocusaurusConfig} from '@docusaurus/types';
3 changes: 2 additions & 1 deletion packages/docusaurus/src/webpack/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export function createBaseConfig(
'@site': siteDir,
'@generated': generatedFilesDir,

'core-js': require.resolve('core-js'),

// Note: a @docusaurus alias would also catch @docusaurus/theme-common,
// so we use fine-grained aliases instead
// '@docusaurus': path.resolve(__dirname, '../client/exports'),
Expand All @@ -153,7 +155,6 @@ export function createBaseConfig(
// 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: [
path.resolve(__dirname, '..', '..', 'node_modules'),
'node_modules',
path.resolve(fs.realpathSync(process.cwd()), 'node_modules'),
],
Expand Down
2 changes: 1 addition & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const isI18nStaging = process.env.I18N_STAGING === 'true';

const isVersioningDisabled = !!process.env.DISABLE_VERSIONING || isI18nStaging;

/** @type {import('@docusaurus/types').DocusaurusConfig} */
/** @type {import('@docusaurus/core/lib').DocusaurusConfig} */
(module.exports = {
title: 'Docusaurus',
tagline: 'Build optimized websites quickly, focus on your content',
Expand Down