diff --git a/docs/package.json b/docs/package.json index f1b7df9c6b7353..46d44a9c12a654 100644 --- a/docs/package.json +++ b/docs/package.json @@ -64,7 +64,7 @@ "next": "^9.0.2", "notistack": "^0.8.6", "postcss": "^7.0.0", - "raw-loader": "^1.0.0", + "raw-loader": "^3.1.0", "react-autosuggest": "^9.4.3", "react-docgen": "^5.0.0-beta.1", "react-dom": "^16.8.5", diff --git a/docs/src/modules/components/MarkdownDocs.js b/docs/src/modules/components/MarkdownDocs.js index b0d6ad7fa322a5..91955086d6f9fb 100644 --- a/docs/src/modules/components/MarkdownDocs.js +++ b/docs/src/modules/components/MarkdownDocs.js @@ -127,9 +127,9 @@ function MarkdownDocs(props) { const match = filename.match(/-([a-z]{2})\.md$/); if (match && LANGUAGES_IN_PROGRESS.indexOf(match[1]) !== -1) { - markdowns[match[1]] = req(filename); + markdowns[match[1]] = req(filename).default; } else { - markdowns.en = req(filename); + markdowns.en = req(filename).default; } } else if (filename.indexOf('.tsx') !== -1) { const demoName = `${reqPrefix}/${filename.replace(/\.\//g, '').replace(/\.tsx/g, '.js')}`; @@ -137,7 +137,7 @@ function MarkdownDocs(props) { demos[demoName] = { ...demos[demoName], tsx: req(filename).default, - rawTS: reqSource(filename), + rawTS: reqSource(filename).default, }; } else { const demoName = `${reqPrefix}/${filename.replace(/\.\//g, '')}`; @@ -145,7 +145,7 @@ function MarkdownDocs(props) { demos[demoName] = { ...demos[demoName], js: req(filename).default, - raw: reqSource(filename), + raw: reqSource(filename).default, }; } }); diff --git a/docs/src/modules/utils/mapTranslations.js b/docs/src/modules/utils/mapTranslations.js index 18da9fb1221d38..4e855a3df8cebc 100644 --- a/docs/src/modules/utils/mapTranslations.js +++ b/docs/src/modules/utils/mapTranslations.js @@ -1,12 +1,21 @@ export default function mapTranslations(req, ext) { const translations = {}; + function load(filename) { + // .md is required by raw-loader which uses ES6 modules + // .json is required with default require semantics which use commonJS + const esModuleRequire = ext === 'md'; + if (esModuleRequire) { + return req(filename).default; + } + return req(filename); + } req.keys().forEach(filename => { const match = filename.match(new RegExp(`-([a-z]{2}).${ext}$`)); if (match) { - translations[match[1]] = req(filename); + translations[match[1]] = load(filename); } else { - translations.en = req(filename); + translations.en = load(filename); } }); return translations; diff --git a/yarn.lock b/yarn.lock index fbb5454eb523ac..87a73b860fc48f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11296,13 +11296,13 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -raw-loader@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-1.0.0.tgz#3f9889e73dadbda9a424bce79809b4133ad46405" - integrity sha512-Uqy5AqELpytJTRxYT4fhltcKPj0TyaEpzJDcGz7DFJi+pQOOi3GjR/DOdxTkTsF+NzhnldIoG6TORaBlInUuqA== +raw-loader@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-3.1.0.tgz#5e9d399a5a222cc0de18f42c3bc5e49677532b3f" + integrity sha512-lzUVMuJ06HF4rYveaz9Tv0WRlUMxJ0Y1hgSkkgg+50iEdaI0TthyEDe08KIHb0XsF6rn8WYTqPCaGTZg3sX+qA== dependencies: loader-utils "^1.1.0" - schema-utils "^1.0.0" + schema-utils "^2.0.1" rc@^1.0.1, rc@^1.1.6, rc@^1.2.7: version "1.2.8" @@ -12388,6 +12388,14 @@ schema-utils@^1.0.0: ajv-errors "^1.0.0" ajv-keywords "^3.1.0" +schema-utils@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.0.1.tgz#1eec2e059556af841b7f3a83b61af13d7a3f9196" + integrity sha512-HJFKJ4JixDpRur06QHwi8uu2kZbng318ahWEKgBjc0ZklcE4FDvmm2wghb448q0IRaABxIESt8vqPFvwgMB80A== + dependencies: + ajv "^6.1.0" + ajv-keywords "^3.1.0" + section-iterator@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/section-iterator/-/section-iterator-2.0.0.tgz#bf444d7afeeb94ad43c39ad2fb26151627ccba2a"