Skip to content

Commit

Permalink
Merge pull request #110 from easyops-cn/steve/faster
Browse files Browse the repository at this point in the history
Update deps and enable Docusaurus faster
  • Loading branch information
weareoutman authored Jan 22, 2025
2 parents 4a47a23 + f6397eb commit c3ce2de
Show file tree
Hide file tree
Showing 5 changed files with 2,488 additions and 1,652 deletions.
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

32 changes: 18 additions & 14 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
const path = require("path");
const { existsSync, readdirSync, readFileSync } = require("fs");
const { createHash } = require("crypto");
const webpack = require("webpack");
const _ = require("lodash");
const CopyPlugin = require("copy-webpack-plugin");
const MonacoEditorWebpackPlugin = require("monaco-editor-webpack-plugin");
const getBricksDir = require("./scripts/getBricksDir.js");

Expand Down Expand Up @@ -118,6 +116,19 @@ const config = {
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "warn",

future: {
// experimental_faster: true,
experimental_faster: {
swcJsLoader: true,
swcJsMinimizer: true,
swcHtmlMinimizer: true,
lightningCssMinimizer: true,
// rspackBundler: false,
rspackBundler: true,
mdxCrossCompilerCache: true,
},
},

// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
Expand Down Expand Up @@ -278,11 +289,12 @@ const config = {
plugins: [
() => ({
name: "docusaurus-next-runtime",
configureWebpack() {
configureWebpack(config, isServer, { currentBundler }) {
const previewDir = path.join(
require.resolve("@next-core/preview/package.json"),
"../dist"
);

return {
mergeStrategy: { "module.rules": "prepend" },
devServer: {
Expand All @@ -296,24 +308,16 @@ const config = {
test: /\.yaml/,
type: "asset/source",
},
{
// This file contains static initialization blocks which are not supported until Chrome 94
test: /[\\/]node_modules[\\/]monaco-editor[\\/]esm[\\/]vs[\\/]language[\\/]typescript[\\/]tsMode\.js$/,
loader: "babel-loader",
options: {
rootMode: "upward",
},
},
],
},
plugins: [
new CopyPlugin({
new currentBundler.instance.CopyRspackPlugin({
patterns: [
{
from: previewDir,
to: "preview",
// Terser skip this file for minimization
info: { minimized: true },
// info: { minimized: true },
transform(buf, filePath) {
if (filePath === path.join(previewDir, "index.html")) {
return buf
Expand Down Expand Up @@ -362,7 +366,7 @@ const config = {
],
filename: `workers/[name].[contenthash:8].worker.js`,
}),
new webpack.NormalModuleReplacementPlugin(
new currentBundler.instance.NormalModuleReplacementPlugin(
new RegExp(`^${_.escapeRegExp(originalFilePath)}$`),
// Refactor without 'd' flag of RegExp
path.resolve(__dirname, "src/replaces/findSectionHeaders.js")
Expand Down
13 changes: 10 additions & 3 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"extends": "./tsconfig.json",
// This file is not used in compilation. It is here just for a nice editor experience.
"extends": "@docusaurus/tsconfig",
"compilerOptions": {
"moduleResolution": "Node"
"baseUrl": ".",
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"strictNullChecks": false
},
"include": ["**/*.js"]
"include": ["**/*.js"],
"exclude": ["node_modules", "build"]
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"prebuild": "node ./scripts/pre-build.mjs"
},
"dependencies": {
"@docusaurus/core": "3.4.0",
"@docusaurus/preset-classic": "3.4.0",
"@docusaurus/core": "3.7.0",
"@docusaurus/preset-classic": "3.7.0",
"@easyops-cn/docusaurus-search-local": "^0.48.3",
"@mdx-js/react": "^3.0.0",
"@next-core/brick-manifest": "^0.7.1",
Expand All @@ -42,12 +42,12 @@
"unified": "^11.0.4"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.4.0",
"@docusaurus/tsconfig": "3.4.0",
"@docusaurus/types": "3.4.0",
"@docusaurus/faster": "^3.7.0",
"@docusaurus/module-type-aliases": "3.7.0",
"@docusaurus/tsconfig": "3.7.0",
"@docusaurus/types": "3.7.0",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"copy-webpack-plugin": "^11.0.0",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-react": "^7.32.2",
Expand Down
Loading

0 comments on commit c3ce2de

Please sign in to comment.