From c2437c7efe47a08bf9a7f9888f51da487727e068 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 24 Oct 2024 23:08:20 +0800 Subject: [PATCH] fix: resolve exports field issue causing README.md loading error in documentation #692 --- core/README.md | 11 ++--------- core/package.json | 7 +++++-- extensions/basic-setup/package.json | 7 +++++-- www/.kktrc.ts | 7 +++---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/core/README.md b/core/README.md index 70b81c342..0891ef117 100644 --- a/core/README.md +++ b/core/README.md @@ -98,7 +98,7 @@ npm install @uiw/react-codemirror --save [![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/react-codemirror-example-codemirror-6-slvju?fontsize=14&hidenavigation=1&theme=dark) -```jsx mdx:preview +```jsx import React from 'react'; import CodeMirror from '@uiw/react-codemirror'; import { javascript } from '@codemirror/lang-javascript'; @@ -272,14 +272,7 @@ import { okaidia } from '@uiw/codemirror-theme-okaidia'; const extensions = [javascript({ jsx: true })]; export default function App() { - return ( - - ); + return ; } ``` diff --git a/core/package.json b/core/package.json index ba959fa23..d15c4e708 100644 --- a/core/package.json +++ b/core/package.json @@ -9,8 +9,11 @@ "main": "./cjs/index.js", "module": "./esm/index.js", "exports": { - "require": "./cjs/index.js", - "import": "./esm/index.js" + ".": { + "require": "./cjs/index.js", + "import": "./esm/index.js" + }, + "./*": "./*" }, "scripts": { "bundle": "ncc build src/index.tsx --target web --filename codemirror && npm run bundle:min", diff --git a/extensions/basic-setup/package.json b/extensions/basic-setup/package.json index 98b3ae96b..c3d06ed15 100644 --- a/extensions/basic-setup/package.json +++ b/extensions/basic-setup/package.json @@ -9,8 +9,11 @@ "main": "./cjs/index.js", "module": "./esm/index.js", "exports": { - "require": "./cjs/index.js", - "import": "./esm/index.js" + ".": { + "require": "./cjs/index.js", + "import": "./esm/index.js" + }, + "./*": "./*" }, "scripts": { "watch": "tsbb watch src/*.ts --use-babel", diff --git a/www/.kktrc.ts b/www/.kktrc.ts index cfe04765e..d5e3dd61b 100644 --- a/www/.kktrc.ts +++ b/www/.kktrc.ts @@ -1,17 +1,16 @@ -import webpack, { Configuration } from 'webpack'; -import { LoaderConfOptions } from 'kkt'; +import webpack from 'webpack'; +import { LoaderConfOptions, WebpackConfiguration } from 'kkt'; import lessModules from '@kkt/less-modules'; import rawModules from '@kkt/raw-modules'; import { disableScopePlugin } from '@kkt/scope-plugin-options'; import { mdCodeModulesLoader } from 'markdown-react-code-preview-loader'; import pkg from './package.json'; -export default (conf: Configuration, env: 'production' | 'development', options: LoaderConfOptions) => { +export default (conf: WebpackConfiguration, env: 'production' | 'development', options: LoaderConfOptions) => { conf = lessModules(conf, env, options); conf = rawModules(conf, env, { ...options, test: /\.(txt)$/i }); conf = mdCodeModulesLoader(conf); conf = disableScopePlugin(conf); - // Get the project version. conf.plugins!.push( new webpack.DefinePlugin({ VERSION: JSON.stringify(pkg.version),