From e656c350dd242196641b23dd2da9a9671836b01b Mon Sep 17 00:00:00 2001 From: slorber Date: Thu, 13 May 2021 20:10:41 +0200 Subject: [PATCH] Enable isolatedModules: true --- .../src/theme/hooks/useDocs.ts | 26 +++++++++++-------- tsconfig.json | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/hooks/useDocs.ts b/packages/docusaurus-theme-classic/src/theme/hooks/useDocs.ts index 985ab8a040..e92c6a8fed 100644 --- a/packages/docusaurus-theme-classic/src/theme/hooks/useDocs.ts +++ b/packages/docusaurus-theme-classic/src/theme/hooks/useDocs.ts @@ -11,19 +11,23 @@ // TODO this is not ideal and produce a warning! // see https://github.com/webpack/webpack/issues/7713#issuecomment-467888437 // note: warning can be filtered: https://github.com/facebook/docusaurus/pull/3382#issuecomment-684966924 -try { - // eslint-disable-next-line global-require - module.exports = require('@theme-init/hooks/useDocs'); -} catch (e) { - // In case the docs plugin is not available, might be useful to stub some methods here - // https://github.com/facebook/docusaurus/issues/3947 - const Empty = {}; - module.exports = { - useAllDocsData: () => Empty, - useActivePluginAndVersion: () => undefined, - }; +function getExport() { + try { + // eslint-disable-next-line global-require + return require('@theme-init/hooks/useDocs'); + } catch (e) { + // In case the docs plugin is not available, might be useful to stub some methods here + // https://github.com/facebook/docusaurus/issues/3947 + const Empty = {}; + return { + useAllDocsData: () => Empty, + useActivePluginAndVersion: () => undefined, + }; + } } +export default getExport(); + /* throw new Error( "The docs plugin is not used, so you can't require the useDocs hooks. ", diff --git a/tsconfig.json b/tsconfig.json index dd7ea79295..61e2b2df31 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,6 +28,7 @@ "moduleResolution": "node", "allowSyntheticDefaultImports": true, "esModuleInterop": true, + "isolatedModules": true, /* Advanced Options */ "resolveJsonModule": true,