Skip to content

Commit

Permalink
fix(deps): update dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 24, 2024
1 parent 9dff6c6 commit 7db14c8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
12 changes: 6 additions & 6 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "https://github.com/kktjs/markdown-react-code-preview-loader"
},
"license": "MIT",
"main": "./lib/index.js",
"main": "lib/index.js",
"module": "esm/index.js",
"types": "lib/index.d.ts",
"files": [
Expand All @@ -25,18 +25,18 @@
"esm"
],
"scripts": {
"build": "tsbb build",
"watch": "tsbb watch"
"build": "tsbb build src/**/*.ts --use-babel",
"watch": "tsbb watch src/**/*.ts --use-babel"
},
"dependencies": {
"@babel/plugin-syntax-unicode-sets-regex": "~7.18.6",
"@babel/standalone": "^7.22.2",
"babel-plugin-transform-remove-imports": "^1.7.0",
"babel-plugin-transform-replace-export-default": "^1.0.3",
"babel-plugin-transform-remove-imports": "^1.8.0",
"babel-plugin-transform-replace-export-default": "^1.0.4",
"remark": "~13.0.0"
},
"devDependencies": {
"@types/babel__standalone": "^7.1.4",
"webpack": "^5.72.0"
"webpack": "^5.95.0"
}
}
9 changes: 5 additions & 4 deletions core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { PluginItem } from '@babel/core';
import { Options as RIOptions } from 'babel-plugin-transform-remove-imports';
import { getProcessor, getCodeBlock, getHeadings, HeadingItem, HeadingListType } from './utils';
import { LoaderDefinitionFunction } from 'webpack';
import { type LoaderDefinitionFunction } from 'webpack';
import { type PluginItem } from '@babel/core';
import { type Options as RIOptions } from 'babel-plugin-transform-remove-imports';
import { getProcessor, getCodeBlock, getHeadings, type HeadingItem, type HeadingListType } from './utils';

export * from './utils';

export type CodeBlockItem = {
Expand Down
7 changes: 4 additions & 3 deletions core/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Parent, Node } from 'unist';
import { type Node } from 'unist';
import webpack from 'webpack';
import remark from 'remark';
import { getTransformValue } from './transform';
import { Options, FUNNAME_PREFIX, CodeBlockItem, CodeBlockData } from '../';
import { type Options, FUNNAME_PREFIX, CodeBlockItem, CodeBlockData } from '../';

/**
* Creates an object containing the parameters of the current URL.
Expand Down Expand Up @@ -32,11 +32,12 @@ export interface MarkdownDataChild extends Node {
children?: Array<MarkdownDataChild>;
}

export interface MarkdownParseData extends Parent<MarkdownDataChild> {}
export interface MarkdownParseData extends MarkdownDataChild {}

/** 转换 代码*/
export const getProcessor = (source: string) => {
try {
// @ts-ignore
const child = remark.parse(source) as MarkdownParseData;
return child.children;
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"⬆️⬆️⬆️⬆️⬆️ package ⬆️⬆️⬆️⬆️⬆️": "▲▲▲▲▲ package ▲▲▲▲▲",
"test": "tsbb test",
"coverage": "tsbb test --coverage --bail",
"prepare": "husky install",
"prepare": "husky",
"version": "lerna version --exact --force-publish --no-push --no-git-tag-version",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"remove": "npm run clean && lerna exec \"rm -rf package-lock.json\" --scope markdown-react-code-preview-loader --scope website",
Expand Down Expand Up @@ -45,4 +45,4 @@
"pretty-quick": "~4.0.0",
"tsbb": "^4.4.0"
}
}
}
24 changes: 22 additions & 2 deletions website/.kktrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import rawModules from '@kkt/raw-modules';
import scopePluginOptions from '@kkt/scope-plugin-options';
import { LoaderConfOptions, WebpackConfiguration } from 'kkt';
import pkg from './package.json';
import { mdCodeModulesLoader } from 'markdown-react-code-preview-loader';
// import { mdCodeModulesLoader } from 'markdown-react-code-preview-loader';

export default (conf: WebpackConfiguration, env: 'development' | 'production', options: LoaderConfOptions) => {
conf = lessModules(conf, env, options);
Expand All @@ -19,8 +19,28 @@ export default (conf: WebpackConfiguration, env: 'development' | 'production', o
VERSION: JSON.stringify(pkg.version),
}),
);
conf = mdCodeModulesLoader(conf);

if (Array.isArray(conf.module?.rules)) {
conf.module?.rules.forEach((ruleItem) => {
if (typeof ruleItem === 'object' && ruleItem !== null) {
if (ruleItem.oneOf) {
ruleItem.oneOf.unshift({
test: /.md$/,
use: [
{
loader: 'markdown-react-code-preview-loader',
options: {},
},
],
});
}
}
});
}

conf.module!.exprContextCritical = false;
/** https://github.com/kktjs/kkt/issues/446 */
conf.ignoreWarnings = [{ module: /node_modules[\\/]parse5[\\/]/ }];

if (process.env.NODE_ENV === 'production') {
conf.output = { ...conf.output, publicPath: './' };
Expand Down

0 comments on commit 7db14c8

Please sign in to comment.