misc: convert all internal scripts to ESM (#6286)

* misc: convert all internal scripts to ESM

* fixes

* fix

* fixes

* fix!

* complete eslint

* more move

* fix!

* This looks better?

* Final ones
This commit is contained in:
Joshua Chen 2022-01-08 12:59:28 +08:00 committed by GitHub
parent bcc05e243f
commit 4fad1ce0cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 412 additions and 374 deletions

View file

@ -5,17 +5,20 @@
* LICENSE file in the root directory of this source tree.
*/
const {normalizeUrl} = require('@docusaurus/utils');
import utils from '@docusaurus/utils';
/**
* @param {import('@docusaurus/types').LoadContext} context
* @returns {import('@docusaurus/types').Plugin}
*/
function FeatureRequestsPlugin(context) {
export default function FeatureRequestsPlugin(context) {
return {
name: 'feature-requests-plugin',
async contentLoaded({actions}) {
const basePath = normalizeUrl([context.baseUrl, '/feature-requests']);
const basePath = utils.normalizeUrl([
context.baseUrl,
'/feature-requests',
]);
await actions.createData('paths.json', JSON.stringify(basePath));
actions.addRoute({
path: basePath,
@ -28,5 +31,3 @@ function FeatureRequestsPlugin(context) {
},
};
}
module.exports = FeatureRequestsPlugin;

View file

@ -5,12 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
const visit = require('unist-util-visit');
import visit from 'unist-util-visit';
/**
* Turns a "```js config-tabs" code block into a "plugin options" and a "preset options" tab
*/
const plugin = () => {
export default function plugin() {
const transformer = (root) => {
let tabsImported = false;
let codeBlockImported = false;
@ -165,6 +165,4 @@ const plugin = () => {
}
};
return transformer;
};
module.exports = plugin;
}

View file

@ -6,9 +6,9 @@
*/
// eslint-disable-next-line import/no-extraneous-dependencies
const darkTheme = require('prism-react-renderer/themes/vsDark');
import darkTheme from 'prism-react-renderer/themes/vsDark/index.cjs.js';
module.exports = {
export default {
plain: {
color: '#D4D4D4',
backgroundColor: '#1E1E1E',

View file

@ -6,9 +6,9 @@
*/
// eslint-disable-next-line import/no-extraneous-dependencies
const lightTheme = require('prism-react-renderer/themes/github');
import lightTheme from 'prism-react-renderer/themes/github/index.cjs.js';
module.exports = {
export default {
...lightTheme,
styles: [
...lightTheme.styles,