diff --git a/rollup.config.js b/rollup.config.js index 8f18209..44c7ee3 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -71,7 +71,12 @@ const builds = [ sourcemap: true } ] - }, + } +]; + +export default [ + ...builds.map(options => configBuild(options, false)), + ...builds.map(options => configBuild(options, true)), { input: "src/index.ts", plugins: [ @@ -90,8 +95,3 @@ const builds = [ } } ]; - -export default [ - ...builds.map(options => configBuild(options, false)), - ...builds.map(options => configBuild(options, true)) -]; diff --git a/scripts/docs.js b/scripts/docs.js index d569a31..c1c8b08 100644 --- a/scripts/docs.js +++ b/scripts/docs.js @@ -1,15 +1,8 @@ import { readFileSync, writeFileSync } from "node:fs"; -import { resolve, dirname } from "node:path"; -import { fileURLToPath } from "node:url"; import commentMark from "comment-mark"; +import { getPackageMeta, resolvePath } from "./utils"; -function resolvePath(...parts) { - return resolve(dirname(fileURLToPath(import.meta.url)), ...parts); -} - -const { name, version } = JSON.parse( - readFileSync(resolvePath("..", "package.json"), "utf8") -); +const { name, version } = getPackageMeta(); const CDN_PREFIX = "https://cdn.jsdelivr.net/npm/"; @@ -45,7 +38,7 @@ const scripts = { }; const README_FILES = ["README.md", "README.zh-Hans.md"].map(name => - resolvePath("..", name) + resolvePath(import.meta.url, "..", name) ); README_FILES.forEach(file => { diff --git a/scripts/postinstall.js b/scripts/postinstall.js index fa5140d..4ee3aa8 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -import path from "node:path"; import fs from "node:fs"; +import { resolvePath } from "./utils.js"; -const packageFile = path.resolve(__dirname, "../package.json"); +const packageFile = resolvePath(import.meta.url, "../package.json"); const typesPaths = { 3: "dist/index.d.ts", diff --git a/scripts/utils.js b/scripts/utils.js new file mode 100644 index 0000000..0147205 --- /dev/null +++ b/scripts/utils.js @@ -0,0 +1,13 @@ +import { readFileSync } from "node:fs"; +import { resolve, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; + +export function resolvePath(url, ...parts) { + return resolve(dirname(fileURLToPath(url)), ...parts); +} + +export function getPackageMeta() { + return JSON.parse( + readFileSync(resolvePath(import.meta.url, "/package.json"), "utf8") + ); +} diff --git a/src/types.ts b/src/types.ts index 102df3d..fb17d80 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ import { init } from "echarts/core"; -import type { Ref } from "vue"; +import type { Ref } from "vue-demi"; import type { SetOptionOpts, ECElementEvent, ElementEvent } from "echarts"; export type Injection = T | null | Ref | { value: T | null };