Skip to content

Commit

Permalink
refactor(theme-classic): migrate to tsc for build (#7447)
Browse files Browse the repository at this point in the history
* refactor(theme-classic): migrate to tsc for build

* fix
  • Loading branch information
Josh-Cena authored May 18, 2022
1 parent 6b53d42 commit b312200
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 104 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ examples/
packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/eslint-plugin/lib/
packages/stylelint-copyright/lib/

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/eslint-plugin/lib/
packages/stylelint-copyright/lib/
packages/docusaurus-*/lib-next/

website/netlifyDeployPreview/*
website/changelog
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ coverage
packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/*/docusaurus.config.js
packages/eslint-plugin/lib/
Expand Down
1 change: 0 additions & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ examples/
packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/
website/static/katex/katex.min.css
1 change: 0 additions & 1 deletion jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const ignorePatterns = [
'/packages/docusaurus-plugin-content-docs/lib',
'/packages/docusaurus-plugin-content-pages/lib',
'/packages/docusaurus-theme-classic/lib',
'/packages/docusaurus-theme-classic/lib-next',
'/packages/docusaurus-theme-common/lib',
'/packages/docusaurus-migrate/lib',
'/jest',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"test": "jest",
"test:build:website": "./admin/scripts/test-release.sh",
"watch": "yarn lerna run --parallel watch",
"clear": "(yarn workspace website clear || echo 'Failure while running docusaurus clear') && yarn lerna exec --ignore docusaurus yarn rimraf lib lib-next",
"clear": "(yarn workspace website clear || echo 'Failure while running docusaurus clear') && yarn lerna exec --ignore docusaurus yarn rimraf lib",
"test:baseUrl": "yarn build:website:baseUrl && yarn serve:website:baseUrl",
"lock:update": "npx yarn-deduplicate"
},
Expand Down
6 changes: 0 additions & 6 deletions packages/docusaurus-theme-classic/.npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
.tsbuildinfo*
tsconfig*
__tests__

lib/theme
lib-next/**
!lib-next/theme/**

babel.config.js
30 changes: 0 additions & 30 deletions packages/docusaurus-theme-classic/babel.config.js

This file was deleted.

18 changes: 6 additions & 12 deletions packages/docusaurus-theme-classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
},
"license": "MIT",
"scripts": {
"build": "tsc --noEmit && yarn babel:lib && yarn babel:lib-next && yarn format:lib-next",
"watch": "run-p --continue-on-error babel:lib:watch babel:lib-next:watch",
"babel:lib": "cross-env BABEL_ENV=lib babel src -d lib --extensions \".tsx,.ts\" --ignore \"**/*.d.ts\" --copy-files",
"babel:lib-next": "cross-env BABEL_ENV=lib-next babel src -d lib-next --extensions \".tsx,.ts\" --ignore \"**/*.d.ts\" --copy-files",
"babel:lib:watch": "yarn babel:lib --watch",
"babel:lib-next:watch": "yarn babel:lib-next --watch",
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.mjs && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"watch": "run-p -c copy:watch build:watch",
"build:watch": "tsc --build --watch",
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.mjs --watch"
},
"dependencies": {
"@docusaurus/core": "2.0.0-beta.20",
Expand All @@ -42,19 +39,16 @@
"prism-react-renderer": "^1.3.3",
"prismjs": "^1.28.0",
"react-router-dom": "^5.2.0",
"rtlcss": "^3.5.0"
"rtlcss": "^3.5.0",
"tslib": "^2.4.0"
},
"devDependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.17.12",
"@babel/preset-typescript": "^7.17.12",
"@docusaurus/module-type-aliases": "2.0.0-beta.20",
"@docusaurus/types": "2.0.0-beta.20",
"@types/mdx-js__react": "^1.5.5",
"@types/nprogress": "^0.2.0",
"@types/prismjs": "^1.26.0",
"@types/rtlcss": "^3.1.4",
"cross-env": "^7.0.3",
"fs-extra": "^10.1.0",
"react-test-renderer": "^17.0.2",
"utility-types": "^3.10.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function themeClassic(
name: 'docusaurus-theme-classic',

getThemePath() {
return '../lib-next/theme';
return '../lib/theme';
},

getTypeScriptThemePath() {
Expand Down
20 changes: 20 additions & 0 deletions packages/docusaurus-theme-classic/tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": false,
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"module": "esnext",
"target": "esnext"
},
"include": [
"src/nprogress.ts",
"src/prism-include-languages.ts",
"src/theme",
"src/*.d.ts"
],
"exclude": ["**/__tests__/**"]
}
19 changes: 14 additions & 5 deletions packages/docusaurus-theme-classic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{
"extends": "../../tsconfig.json",
"references": [{"path": "./tsconfig.client.json"}],
"compilerOptions": {
"lib": ["DOM", "ES2019"],
"module": "esnext",
"noEmit": true
"noEmit": false,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "commonjs",
"rootDir": "src",
"outDir": "lib"
},
"include": ["src/"],
"exclude": ["**/__tests__/**"]
"include": ["src"],
"exclude": [
"src/nprogress.ts",
"src/prism-include-languages.ts",
"src/theme",
"**/__tests__/**"
]
}
5 changes: 1 addition & 4 deletions packages/docusaurus-theme-translations/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ async function getPackageCodePath(packageName: string) {
const packageJsonPath = path.join(packagePath, 'package.json');
const {main} = await fs.readJSON(packageJsonPath);
const packageSrcPath = path.join(packagePath, path.dirname(main));
const packageLibNextPath = packageSrcPath.replace('lib', 'lib-next');
return (await fs.pathExists(packageLibNextPath))
? packageLibNextPath
: packageSrcPath;
return packageSrcPath;
}

export async function getThemes(): Promise<{name: string; src: string[]}[]> {
Expand Down
2 changes: 1 addition & 1 deletion website/_dogfooding/testSwizzleThemeClassic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const classicThemePathBase = path.join(

const themePath = swizzleConfig
? path.join(classicThemePathBase, 'src/theme')
: path.join(classicThemePathBase, 'lib-next/theme');
: path.join(classicThemePathBase, 'lib/theme');

const toPath = path.join(dirname, '_swizzle_theme_tests');

Expand Down
42 changes: 3 additions & 39 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,6 @@
jsonpointer "^5.0.0"
leven "^3.1.0"

"@babel/cli@^7.17.10":
version "7.17.10"
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.17.10.tgz#5ea0bf6298bb78f3b59c7c06954f9bd1c79d5943"
integrity sha512-OygVO1M2J4yPMNOW9pb+I6kFGpQK77HmG44Oz3hg8xQIl5L/2zq+ZohwAdSaqYgVwM0SfmPHZHphH4wR8qzVYw==
dependencies:
"@jridgewell/trace-mapping" "^0.3.8"
commander "^4.0.1"
convert-source-map "^1.1.0"
fs-readdir-recursive "^1.1.0"
glob "^7.0.0"
make-dir "^2.1.0"
slash "^2.0.0"
optionalDependencies:
"@nicolo-ribaudo/chokidar-2" "2.1.8-no-fsevents.3"
chokidar "^3.4.0"

"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.8.3":
version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789"
Expand Down Expand Up @@ -1872,7 +1856,7 @@
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz#b6461fb0c2964356c469e115f504c95ad97ab88c"
integrity sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w==

"@jridgewell/trace-mapping@^0.3.7", "@jridgewell/trace-mapping@^0.3.8", "@jridgewell/trace-mapping@^0.3.9":
"@jridgewell/trace-mapping@^0.3.7", "@jridgewell/trace-mapping@^0.3.9":
version "0.3.13"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz#dcfe3e95f224c8fe97a87a5235defec999aa92ea"
integrity sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w==
Expand Down Expand Up @@ -2611,11 +2595,6 @@
dependencies:
is-promise "^4.0.0"

"@nicolo-ribaudo/[email protected]":
version "2.1.8-no-fsevents.3"
resolved "https://registry.yarnpkg.com/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz#323d72dd25103d0c4fbdce89dadf574a787b1f9b"
integrity sha512-s88O1aVtXftvp5bCPB7WnmXc5IwOZZ7YPuwNPt+GtOOXpPvad1LfbmjYv+qII7zP6RU2QGnqve27dnLycEnyEQ==

"@nodelib/[email protected]":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -5219,7 +5198,7 @@ cheerio@^1.0.0-rc.10:
parse5-htmlparser2-tree-adapter "^6.0.1"
tslib "^2.2.0"

chokidar@^3.4.0, chokidar@^3.4.2, chokidar@^3.5.3:
chokidar@^3.4.2, chokidar@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
Expand Down Expand Up @@ -5520,11 +5499,6 @@ commander@^2.20.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

commander@^4.0.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068"
integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==

commander@^5.0.0, commander@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
Expand Down Expand Up @@ -5773,7 +5747,7 @@ conventional-recommended-bump@^6.1.0:
meow "^8.0.0"
q "^1.5.1"

convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369"
integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==
Expand Down Expand Up @@ -7615,11 +7589,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.3.tgz#ae3ac92d53bb328efe0e9a1d9541f6ad8d48e2d3"
integrity sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==

fs-readdir-recursive@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27"
integrity sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down Expand Up @@ -13670,11 +13639,6 @@ sitemap@^7.1.1:
arg "^5.0.0"
sax "^1.2.4"

slash@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==

slash@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
Expand Down

0 comments on commit b312200

Please sign in to comment.