mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
refactor(theme-classic): migrate to tsc for build (#7447)
* refactor(theme-classic): migrate to tsc for build * fix
This commit is contained in:
parent
6b53d4263d
commit
b31220032b
15 changed files with 47 additions and 104 deletions
|
@ -1,9 +1,3 @@
|
|||
.tsbuildinfo*
|
||||
tsconfig*
|
||||
__tests__
|
||||
|
||||
lib/theme
|
||||
lib-next/**
|
||||
!lib-next/theme/**
|
||||
|
||||
babel.config.js
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
// USED FOR NODE/RUNTIME
|
||||
// maybe we should differentiate both cases because
|
||||
// we mostly need to transpile some features so that node does not crash...
|
||||
lib: {
|
||||
presets: [
|
||||
['@babel/preset-env', {targets: {node: 14}, modules: 'commonjs'}],
|
||||
['@babel/preset-typescript', {isTSX: true, allExtensions: true}],
|
||||
],
|
||||
},
|
||||
|
||||
// USED FOR JS SWIZZLE
|
||||
// /lib-next folder is used as source to swizzle JS source code
|
||||
// This JS code is created from TS source code
|
||||
// This source code should look clean/human readable to be usable
|
||||
'lib-next': {
|
||||
presets: [
|
||||
['@babel/preset-typescript', {isTSX: true, allExtensions: true}],
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
|
@ -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",
|
||||
|
@ -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"
|
||||
|
|
|
@ -112,7 +112,7 @@ export default function themeClassic(
|
|||
name: 'docusaurus-theme-classic',
|
||||
|
||||
getThemePath() {
|
||||
return '../lib-next/theme';
|
||||
return '../lib/theme';
|
||||
},
|
||||
|
||||
getTypeScriptThemePath() {
|
||||
|
|
20
packages/docusaurus-theme-classic/tsconfig.client.json
Normal file
20
packages/docusaurus-theme-classic/tsconfig.client.json
Normal file
|
@ -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__/**"]
|
||||
}
|
|
@ -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__/**"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue