fix: remove deprecated createRequireFromPath (#5496)

This commit is contained in:
Alexey Pyltsyn 2021-09-11 12:39:33 +03:00 committed by GitHub
parent 0f5efc976f
commit 453d9c099d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 10 deletions

View file

@ -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'),
);

View file

@ -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(

View file

@ -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 || [];