@docusaurus/core 4.0.0-canary-6834 → 4.0.0-canary-6839

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.
@@ -24,7 +24,7 @@ type WatchParams = {
24
24
  * Watch file system paths for changes and emit events
25
25
  * Returns an async handle to stop watching
26
26
  */
27
- export declare function watch(params: WatchParams, callback: (event: FileWatchEvent) => void): () => Promise<void>;
27
+ export declare function watchPaths(params: WatchParams, callback: (event: FileWatchEvent) => void): () => Promise<void>;
28
28
  export declare function getSitePathsToWatch({ props }: {
29
29
  props: Props;
30
30
  }): string[];
@@ -7,13 +7,13 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createPollingOptions = createPollingOptions;
10
- exports.watch = watch;
10
+ exports.watchPaths = watchPaths;
11
11
  exports.getSitePathsToWatch = getSitePathsToWatch;
12
12
  exports.getPluginPathsToWatch = getPluginPathsToWatch;
13
13
  exports.setupSiteFileWatchers = setupSiteFileWatchers;
14
14
  const tslib_1 = require("tslib");
15
15
  const path_1 = tslib_1.__importDefault(require("path"));
16
- const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
16
+ const glob_1 = require("@docusaurus/glob");
17
17
  const utils_1 = require("@docusaurus/utils");
18
18
  function createPollingOptions(cliOptions) {
19
19
  return {
@@ -27,15 +27,15 @@ function createPollingOptions(cliOptions) {
27
27
  * Watch file system paths for changes and emit events
28
28
  * Returns an async handle to stop watching
29
29
  */
30
- function watch(params, callback) {
30
+ function watchPaths(params, callback) {
31
31
  const { pathsToWatch, siteDir, ...options } = params;
32
- const fsWatcher = chokidar_1.default.watch(pathsToWatch, {
32
+ const watcher = (0, glob_1.watch)(pathsToWatch, {
33
33
  cwd: siteDir,
34
34
  ignoreInitial: true,
35
35
  ...options,
36
36
  });
37
- fsWatcher.on('all', (name, eventPath) => callback({ name, path: eventPath }));
38
- return () => fsWatcher.close();
37
+ watcher.on('all', (name, eventPath) => callback({ name, path: eventPath }));
38
+ return () => watcher.close();
39
39
  }
40
40
  function getSitePathsToWatch({ props }) {
41
41
  return [
@@ -62,13 +62,13 @@ function setupSiteFileWatchers({ props, cliOptions, }, callback) {
62
62
  // TODO on config / or local plugin updates,
63
63
  // the getFilePathsToWatch lifecycle code might get updated
64
64
  // so we should probably reset the watchers?
65
- watch({
65
+ watchPaths({
66
66
  pathsToWatch: getSitePathsToWatch({ props }),
67
67
  siteDir: props.siteDir,
68
68
  ...pollingOptions,
69
69
  }, (event) => callback({ plugin: null, event }));
70
70
  props.plugins.forEach((plugin) => {
71
- watch({
71
+ watchPaths({
72
72
  pathsToWatch: getPluginPathsToWatch({ plugin, siteDir }),
73
73
  siteDir,
74
74
  ...pollingOptions,
@@ -16,6 +16,7 @@ const path_1 = tslib_1.__importDefault(require("path"));
16
16
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
17
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
18
18
  const utils_1 = require("@docusaurus/utils");
19
+ const glob_1 = require("@docusaurus/glob");
19
20
  const prompts_1 = require("./prompts");
20
21
  exports.SwizzleActions = ['wrap', 'eject'];
21
22
  async function getAction(componentConfig, options) {
@@ -38,7 +39,7 @@ async function eject({ siteDir, themePath, componentName, typescript, }) {
38
39
  path_1.default.join(fromPath, '**/*')
39
40
  : `${fromPath}.*`;
40
41
  const globPatternPosix = (0, utils_1.posixPath)(globPattern);
41
- const filesToCopy = await (0, utils_1.Globby)(globPatternPosix, {
42
+ const filesToCopy = await (0, glob_1.glob)(globPatternPosix, {
42
43
  // Workaround for Tinyglobby bug?
43
44
  // We glob absolute from the theme root path, not from cwd
44
45
  // See https://github.com/SuperchupuDev/tinyglobby/issues/186
@@ -11,6 +11,7 @@ const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
13
  const utils_1 = require("@docusaurus/utils");
14
+ const glob_1 = require("@docusaurus/glob");
14
15
  const site_1 = require("../server/site");
15
16
  const init_1 = require("../server/plugins/init");
16
17
  function inferFallbackSyntax(_filepath) {
@@ -38,6 +39,10 @@ async function transformMarkdownFile(filepath, options) {
38
39
  }
39
40
  return undefined;
40
41
  }
42
+ async function globMarkdownFiles(patterns) {
43
+ const files = await (0, glob_1.safeGlob)(patterns);
44
+ return files.filter((file) => file.endsWith('.md') || file.endsWith('.mdx'));
45
+ }
41
46
  /**
42
47
  * We only handle the "paths to watch" because these are the paths where the
43
48
  * markdown files are. Also we don't want to transform the site md docs that do
@@ -63,9 +68,7 @@ async function writeHeadingIds(siteDirParam = '.', files = [], options = {}) {
63
68
  validateOptions(options);
64
69
  const siteDir = await fs_extra_1.default.realpath(siteDirParam);
65
70
  const patterns = files.length ? files : await getPathsToWatch(siteDir);
66
- const markdownFiles = (await (0, utils_1.safeGlobby)(patterns, {
67
- expandDirectories: true,
68
- })).filter((file) => file.endsWith('.md') || file.endsWith('.mdx'));
71
+ const markdownFiles = await globMarkdownFiles(patterns);
69
72
  if (markdownFiles.length === 0) {
70
73
  logger_1.default.warn `No markdown files found in siteDir path=${siteDir} for patterns: ${patterns}`;
71
74
  return;
@@ -10,7 +10,7 @@ exports.writeTranslations = writeTranslations;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const path_1 = tslib_1.__importDefault(require("path"));
13
- const utils_1 = require("@docusaurus/utils");
13
+ const glob_1 = require("@docusaurus/glob");
14
14
  const site_1 = require("../server/site");
15
15
  const init_1 = require("../server/plugins/init");
16
16
  const translations_1 = require("../server/translations/translations");
@@ -35,7 +35,7 @@ async function getExtraSourceCodeFilePaths() {
35
35
  if (!themeCommonLibDir) {
36
36
  return []; // User may not use a Docusaurus official theme? Quite unlikely...
37
37
  }
38
- return (0, utils_1.globTranslatableSourceFiles)([themeCommonLibDir]);
38
+ return (0, glob_1.globTranslatableSourceFiles)([themeCommonLibDir]);
39
39
  }
40
40
  async function writePluginTranslationFiles({ localizationDir, plugin, options, }) {
41
41
  if (plugin.getTranslationFiles) {
@@ -95,6 +95,7 @@ async function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
95
95
  {
96
96
  test: /\.mdx?$/i,
97
97
  exclude: getMDXFallbackExcludedPaths(),
98
+ with: { type: { not: 'text' } },
98
99
  use: [mdxLoaderItem],
99
100
  },
100
101
  ],
@@ -11,6 +11,7 @@ const tslib_1 = require("tslib");
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
13
  const utils_1 = require("@docusaurus/utils");
14
+ const glob_1 = require("@docusaurus/glob");
14
15
  const babel_1 = require("@docusaurus/babel");
15
16
  function getSiteSourceCodeFilePaths(siteDir) {
16
17
  return [path_1.default.join(siteDir, utils_1.SRC_DIR_NAME)];
@@ -36,7 +37,7 @@ async function getSourceCodeFilePaths(siteDir, plugins) {
36
37
  // new lifecycle method for that???
37
38
  const pluginsPaths = plugins.flatMap(getPluginSourceCodeFilePaths);
38
39
  const allPaths = [...sitePaths, ...pluginsPaths];
39
- return (0, utils_1.globTranslatableSourceFiles)(allPaths);
40
+ return (0, glob_1.globTranslatableSourceFiles)(allPaths);
40
41
  }
41
42
  async function extractSiteSourceCodeTranslations({ siteDir, plugins, extraSourceCodeFilePaths = [], }) {
42
43
  const babelOptions = (0, babel_1.getBabelOptions)({
@@ -15,6 +15,7 @@ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
15
  const path_1 = tslib_1.__importDefault(require("path"));
16
16
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
17
  const utils_1 = require("@docusaurus/utils");
18
+ const glob_1 = require("@docusaurus/glob");
18
19
  const ThemeFallbackDir = path_1.default.join(__dirname, '../../client/theme-fallback');
19
20
  /**
20
21
  * Order of Webpack aliases is important because one alias can shadow another.
@@ -37,7 +38,7 @@ async function createAliasesForTheme(themePath, addOriginalAlias) {
37
38
  if (!(await fs_extra_1.default.pathExists(themePath))) {
38
39
  return {};
39
40
  }
40
- const themeComponentFiles = await (0, utils_1.Globby)(['**/*.{js,jsx,ts,tsx}'], {
41
+ const themeComponentFiles = await (0, glob_1.glob)(['**/*.{js,jsx,ts,tsx}'], {
41
42
  cwd: themePath,
42
43
  ignore: [
43
44
  // Ignore co-located test files
@@ -109,6 +109,7 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
109
109
  },
110
110
  };
111
111
  }
112
+ const notTextImport = { type: { not: 'text' } };
112
113
  return {
113
114
  mode,
114
115
  name,
@@ -212,6 +213,7 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
212
213
  {
213
214
  test: /\.[jt]sx?$/i,
214
215
  exclude: excludeJS,
216
+ with: notTextImport,
215
217
  use: [
216
218
  createJsLoader({
217
219
  isServer,
@@ -222,6 +224,7 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
222
224
  {
223
225
  test: CSS_REGEX,
224
226
  exclude: CSS_MODULE_REGEX,
227
+ with: notTextImport,
225
228
  use: configureWebpackUtils.getStyleLoaders(isServer, {
226
229
  importLoaders: 1,
227
230
  sourceMap: !isProd,
@@ -231,6 +234,7 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
231
234
  // using the extension .module.css
232
235
  {
233
236
  test: CSS_MODULE_REGEX,
237
+ with: notTextImport,
234
238
  use: configureWebpackUtils.getStyleLoaders(isServer, {
235
239
  modules: {
236
240
  // Using the same CSS Module class pattern in dev/prod on purpose
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": "4.0.0-canary-6834",
4
+ "version": "4.0.0-canary-6839",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -33,15 +33,15 @@
33
33
  "url": "https://github.com/facebook/docusaurus/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@docusaurus/babel": "4.0.0-canary-6834",
37
- "@docusaurus/bundler": "4.0.0-canary-6834",
38
- "@docusaurus/logger": "4.0.0-canary-6834",
39
- "@docusaurus/mdx-loader": "4.0.0-canary-6834",
40
- "@docusaurus/utils": "4.0.0-canary-6834",
41
- "@docusaurus/utils-common": "4.0.0-canary-6834",
42
- "@docusaurus/utils-validation": "4.0.0-canary-6834",
36
+ "@docusaurus/babel": "4.0.0-canary-6839",
37
+ "@docusaurus/bundler": "4.0.0-canary-6839",
38
+ "@docusaurus/glob": "4.0.0-canary-6839",
39
+ "@docusaurus/logger": "4.0.0-canary-6839",
40
+ "@docusaurus/mdx-loader": "4.0.0-canary-6839",
41
+ "@docusaurus/utils": "4.0.0-canary-6839",
42
+ "@docusaurus/utils-common": "4.0.0-canary-6839",
43
+ "@docusaurus/utils-validation": "4.0.0-canary-6839",
43
44
  "boxen": "^8.0.1",
44
- "chokidar": "^3.6.0",
45
45
  "cli-table3": "^0.6.5",
46
46
  "combine-promises": "^1.2.0",
47
47
  "commander": "^15.0.0",
@@ -76,8 +76,8 @@
76
76
  "webpack-merge": "^6.0.1"
77
77
  },
78
78
  "devDependencies": {
79
- "@docusaurus/module-type-aliases": "4.0.0-canary-6834",
80
- "@docusaurus/types": "4.0.0-canary-6834",
79
+ "@docusaurus/module-type-aliases": "4.0.0-canary-6839",
80
+ "@docusaurus/types": "4.0.0-canary-6839",
81
81
  "@total-typescript/shoehorn": "^0.1.2",
82
82
  "@types/escape-html": "^1.0.4",
83
83
  "@types/history": "^4.7.11",
@@ -91,7 +91,7 @@
91
91
  "tree-node-cli": "^3.0.0"
92
92
  },
93
93
  "peerDependencies": {
94
- "@docusaurus/faster": "4.0.0-canary-6834",
94
+ "@docusaurus/faster": "4.0.0-canary-6839",
95
95
  "@mdx-js/react": "^3.1.1",
96
96
  "react": "^19.3.0",
97
97
  "react-dom": "^19.3.0"
@@ -104,5 +104,5 @@
104
104
  "engines": {
105
105
  "node": ">=24.21"
106
106
  },
107
- "gitHead": "a0e0065eb05cabc94cdf34aeea046f65754c4ecd"
107
+ "gitHead": "c93a33b60c528917c38fbf07e54c14ff52bdc190"
108
108
  }