@docusaurus/core 0.0.0-6056 → 0.0.0-6060

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -136,7 +136,7 @@ async function loadPlugins(context) {
136
136
  return utils_1.PerfLogger.async('Load plugins', async () => {
137
137
  const initializedPlugins = await utils_1.PerfLogger.async('Init plugins', () => (0, init_1.initPlugins)(context));
138
138
  // TODO probably not the ideal place to hardcode those plugins
139
- initializedPlugins.push((0, synthetic_1.createBootstrapPlugin)(context), (0, synthetic_1.createMDXFallbackPlugin)(context));
139
+ initializedPlugins.push((0, synthetic_1.createBootstrapPlugin)(context), await (0, synthetic_1.createMDXFallbackPlugin)(context));
140
140
  const plugins = await executeAllPluginsContentLoading({
141
141
  plugins: initializedPlugins,
142
142
  context,
@@ -17,4 +17,4 @@ export declare function createBootstrapPlugin({ siteDir, siteConfig, }: LoadCont
17
17
  * content plugins. This allows to do things such as importing repo/README.md as
18
18
  * a partial from another doc. Not ideal solution, but good enough for now
19
19
  */
20
- export declare function createMDXFallbackPlugin({ siteDir, siteConfig, }: LoadContext): InitializedPlugin;
20
+ export declare function createMDXFallbackPlugin({ siteDir, siteConfig, }: LoadContext): Promise<InitializedPlugin>;
@@ -10,6 +10,7 @@ exports.createBootstrapPlugin = createBootstrapPlugin;
10
10
  exports.createMDXFallbackPlugin = createMDXFallbackPlugin;
11
11
  const tslib_1 = require("tslib");
12
12
  const path_1 = tslib_1.__importDefault(require("path"));
13
+ const mdx_loader_1 = require("@docusaurus/mdx-loader");
13
14
  /**
14
15
  * Make a synthetic plugin to:
15
16
  * - Inject site client modules
@@ -57,7 +58,17 @@ function createBootstrapPlugin({ siteDir, siteConfig, }) {
57
58
  * content plugins. This allows to do things such as importing repo/README.md as
58
59
  * a partial from another doc. Not ideal solution, but good enough for now
59
60
  */
60
- function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
61
+ async function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
62
+ const mdxLoaderItem = await (0, mdx_loader_1.createMDXLoaderItem)({
63
+ admonitions: true,
64
+ staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
65
+ siteDir,
66
+ // External MDX files are always meant to be imported as partials
67
+ isMDXPartial: () => true,
68
+ // External MDX files might have front matter, just disable the warning
69
+ isMDXPartialFrontMatterWarningDisabled: true,
70
+ markdownConfig: siteConfig.markdown,
71
+ });
61
72
  return {
62
73
  name: 'docusaurus-mdx-fallback-plugin',
63
74
  options: {
@@ -77,28 +88,13 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
77
88
  return isMDXRule ? rule.include : [];
78
89
  });
79
90
  }
80
- const mdxLoaderOptions = {
81
- admonitions: true,
82
- staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
83
- siteDir,
84
- // External MDX files are always meant to be imported as partials
85
- isMDXPartial: () => true,
86
- // External MDX files might have front matter, just disable the warning
87
- isMDXPartialFrontMatterWarningDisabled: true,
88
- markdownConfig: siteConfig.markdown,
89
- };
90
91
  return {
91
92
  module: {
92
93
  rules: [
93
94
  {
94
95
  test: /\.mdx?$/i,
95
96
  exclude: getMDXFallbackExcludedPaths(),
96
- use: [
97
- {
98
- loader: require.resolve('@docusaurus/mdx-loader'),
99
- options: mdxLoaderOptions,
100
- },
101
- ],
97
+ use: [mdxLoaderItem],
102
98
  },
103
99
  ],
104
100
  },
@@ -50,6 +50,8 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) {
50
50
  esModule: false,
51
51
  ...cssOptionsArg,
52
52
  };
53
+ // On the server we don't really need to extract/emit CSS
54
+ // We only need to transform CSS module imports to a styles object
53
55
  if (isServer) {
54
56
  return cssOptions.modules
55
57
  ? [
@@ -58,20 +60,8 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) {
58
60
  options: cssOptions,
59
61
  },
60
62
  ]
61
- : [
62
- {
63
- loader: mini_css_extract_plugin_1.default.loader,
64
- options: {
65
- // Don't emit CSS files for SSR (previously used null-loader)
66
- // See https://github.com/webpack-contrib/mini-css-extract-plugin/issues/90#issuecomment-811991738
67
- emit: false,
68
- },
69
- },
70
- {
71
- loader: require.resolve('css-loader'),
72
- options: cssOptions,
73
- },
74
- ];
63
+ : // Ignore regular CSS files
64
+ [{ loader: require.resolve('null-loader') }];
75
65
  }
76
66
  return [
77
67
  {
@@ -84,6 +74,11 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) {
84
74
  loader: require.resolve('css-loader'),
85
75
  options: cssOptions,
86
76
  },
77
+ // TODO apart for configurePostCss(), do we really need this loader?
78
+ // Note: using postcss here looks inefficient/duplicate
79
+ // But in practice, it's not a big deal because css-loader also uses postcss
80
+ // and is able to reuse the parsed AST from postcss-loader
81
+ // See https://github.com/webpack-contrib/css-loader/blob/master/src/index.js#L159
87
82
  {
88
83
  // Options for PostCSS as we reference these options twice
89
84
  // Adds vendor prefixing based on your specified browser support in
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "0.0.0-6056",
4
+ "version": "0.0.0-6060",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,12 +43,12 @@
43
43
  "@babel/runtime": "^7.22.6",
44
44
  "@babel/runtime-corejs3": "^7.22.6",
45
45
  "@babel/traverse": "^7.22.8",
46
- "@docusaurus/cssnano-preset": "0.0.0-6056",
47
- "@docusaurus/logger": "0.0.0-6056",
48
- "@docusaurus/mdx-loader": "0.0.0-6056",
49
- "@docusaurus/utils": "0.0.0-6056",
50
- "@docusaurus/utils-common": "0.0.0-6056",
51
- "@docusaurus/utils-validation": "0.0.0-6056",
46
+ "@docusaurus/cssnano-preset": "0.0.0-6060",
47
+ "@docusaurus/logger": "0.0.0-6060",
48
+ "@docusaurus/mdx-loader": "0.0.0-6060",
49
+ "@docusaurus/utils": "0.0.0-6060",
50
+ "@docusaurus/utils-common": "0.0.0-6060",
51
+ "@docusaurus/utils-validation": "0.0.0-6060",
52
52
  "autoprefixer": "^10.4.14",
53
53
  "babel-loader": "^9.1.3",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
@@ -77,6 +77,7 @@
77
77
  "leven": "^3.1.0",
78
78
  "lodash": "^4.17.21",
79
79
  "mini-css-extract-plugin": "^2.7.6",
80
+ "null-loader": "^4.0.1",
80
81
  "p-map": "^4.0.0",
81
82
  "postcss": "^8.4.26",
82
83
  "postcss-loader": "^7.3.3",
@@ -103,8 +104,8 @@
103
104
  "webpackbar": "^5.0.2"
104
105
  },
105
106
  "devDependencies": {
106
- "@docusaurus/module-type-aliases": "0.0.0-6056",
107
- "@docusaurus/types": "0.0.0-6056",
107
+ "@docusaurus/module-type-aliases": "0.0.0-6060",
108
+ "@docusaurus/types": "0.0.0-6060",
108
109
  "@total-typescript/shoehorn": "^0.1.2",
109
110
  "@types/detect-port": "^1.3.3",
110
111
  "@types/react-dom": "^18.2.7",
@@ -131,5 +132,5 @@
131
132
  "engines": {
132
133
  "node": ">=18.0"
133
134
  },
134
- "gitHead": "acf50a339a52a999dd474ff7e5b610b4227b8362"
135
+ "gitHead": "75cf549134cde8901d2598e6c6d2439a334512ff"
135
136
  }