mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-17 08:37:57 +02:00
fix: remove deprecated createRequireFromPath (#5496)
This commit is contained in:
parent
0f5efc976f
commit
453d9c099d
3 changed files with 3 additions and 10 deletions
|
@ -9,12 +9,11 @@ import {DocusaurusContext, Plugin} from '@docusaurus/types';
|
|||
import type {ThemeConfig} from '@docusaurus/theme-common';
|
||||
import {getTranslationFiles, translateThemeConfig} from './translations';
|
||||
import path from 'path';
|
||||
import Module from 'module';
|
||||
import {createRequire} from 'module';
|
||||
import type {AcceptedPlugin, Plugin as PostCssPlugin} from 'postcss';
|
||||
import rtlcss from 'rtlcss';
|
||||
import {readDefaultCodeTranslationMessages} from '@docusaurus/utils';
|
||||
|
||||
const createRequire = Module.createRequire || Module.createRequireFromPath;
|
||||
const requireFromDocusaurusCore = createRequire(
|
||||
require.resolve('@docusaurus/core/package.json'),
|
||||
);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Module from 'module';
|
||||
import {createRequire} from 'module';
|
||||
import importFresh from 'import-fresh';
|
||||
import {
|
||||
DocusaurusPluginVersionInformation,
|
||||
|
@ -133,9 +133,6 @@ export default function initPlugins({
|
|||
}): InitializedPlugin[] {
|
||||
// We need to resolve plugins from the perspective of the siteDir, since the siteDir's package.json
|
||||
// declares the dependency on these plugins.
|
||||
// We need to fallback to createRequireFromPath since createRequire is only available in node v12.
|
||||
// See: https://nodejs.org/api/modules.html#modules_module_createrequire_filename
|
||||
const createRequire = Module.createRequire || Module.createRequireFromPath;
|
||||
const pluginRequire = createRequire(context.siteConfigPath);
|
||||
|
||||
function doGetPluginVersion(
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Module from 'module';
|
||||
import {createRequire} from 'module';
|
||||
import importFresh from 'import-fresh';
|
||||
import {
|
||||
LoadContext,
|
||||
|
@ -22,9 +22,6 @@ export default function loadPresets(
|
|||
} {
|
||||
// We need to resolve plugins from the perspective of the siteDir, since the siteDir's package.json
|
||||
// declares the dependency on these plugins.
|
||||
// We need to fallback to createRequireFromPath since createRequire is only available in node v12.
|
||||
// See: https://nodejs.org/api/modules.html#modules_module_createrequire_filename
|
||||
const createRequire = Module.createRequire || Module.createRequireFromPath;
|
||||
const pluginRequire = createRequire(context.siteConfigPath);
|
||||
|
||||
const presets: PresetConfig[] = (context.siteConfig || {}).presets || [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue