From 8469b0146a229ec123e9ba42b7621bacbf50353f Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 16 Sep 2021 22:27:36 +0800 Subject: [PATCH] fix: compatible esm/mjs requirements. --- package.json | 4 +++- src/index.ts | 4 ++-- src/utils.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ae260f0..9813a76 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "prepack": "npm run build", "start": "node lib/index.js", "watch": "tsbb watch --disable-babel", - "build": "tsbb build --disable-babel", + "build": "tsbb build --disable-babel && npm run esm-fix", + "esm-fix": "tsc-esm-fix --target='lib' --ext='.js'", "test": "tsbb test", "coverage": "tsbb test --coverage" }, @@ -55,6 +56,7 @@ "remark-gfm": "2.0.0", "remark-parse": "10.0.0", "remark-rehype": "9.0.0", + "tsc-esm-fix": "2.7.2", "tsbb": "3.2.1" } } diff --git a/src/index.ts b/src/index.ts index e073f7d..f6684b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { Plugin, Transformer } from 'unified'; import { Parent, NodeData, Node } from 'unist'; -import visit from './visit.js'; -import { propertiesHandle, nextChild, prevChild, getCommentObject } from './utils.js'; +import visit from './visit'; +import { propertiesHandle, nextChild, prevChild, getCommentObject } from './utils'; export type RehypeAttrsOptions = { /** diff --git a/src/utils.ts b/src/utils.ts index 0861ba9..05865b9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,5 @@ import { Parent, NodeData } from 'unist'; -import { RehypeAttrsOptions } from './index.js'; +import { RehypeAttrsOptions } from './'; export const getURLParameters = (url: string): Record => (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce(