diff --git a/package.json b/package.json index 9d6285c..cf1df5d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dev": "vite dev", "build": "vite build", "preview": "vite preview", - "package": "svelte-kit sync && svelte-package && publint", + "package": "svelte-kit sync && svelte-package -i ./src/lib/svelte-echarts && publint", "prepublishOnly": "npm run package", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", diff --git a/src/lib/index.ts b/src/lib/index.ts deleted file mode 100644 index f09a8be..0000000 --- a/src/lib/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as Chart } from '$lib/components/Chart.svelte' -export type { ECMouseEvent, ECInteractionEvent } from '$lib/constants/events' diff --git a/src/lib/components/Chart.svelte b/src/lib/svelte-echarts/components/Chart.svelte similarity index 94% rename from src/lib/components/Chart.svelte rename to src/lib/svelte-echarts/components/Chart.svelte index 2433118..4824863 100644 --- a/src/lib/components/Chart.svelte +++ b/src/lib/svelte-echarts/components/Chart.svelte @@ -3,7 +3,7 @@ import type { init as coreInit, EChartsType as CoreEchartsType } from 'echarts/core' import type { EChartsOption, EChartsInitOpts } from 'echarts' import { createEventDispatcher } from 'svelte' - import { EVENT_NAMES, type EventHandlers } from '$lib/constants/events' + import { EVENT_NAMES, type EventHandlers } from '$lib/svelte-echarts/constants/events' import type { Action } from 'svelte/action' export let init: typeof baseInit | typeof coreInit diff --git a/src/lib/constants/events.ts b/src/lib/svelte-echarts/constants/events.ts similarity index 100% rename from src/lib/constants/events.ts rename to src/lib/svelte-echarts/constants/events.ts diff --git a/src/lib/svelte-echarts/index.ts b/src/lib/svelte-echarts/index.ts new file mode 100644 index 0000000..bd3aa0e --- /dev/null +++ b/src/lib/svelte-echarts/index.ts @@ -0,0 +1,2 @@ +export { default as Chart } from '$lib/svelte-echarts/components/Chart.svelte' +export type { ECMouseEvent, ECInteractionEvent } from '$lib/svelte-echarts/constants/events' diff --git a/src/lib/types.ts b/src/lib/svelte-echarts/types.ts similarity index 100% rename from src/lib/types.ts rename to src/lib/svelte-echarts/types.ts diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index db8a7ee..9ea90b5 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,7 +1,6 @@ diff --git a/src/routes/examples/classic/+page.svelte b/src/routes/examples/classic/+page.svelte index 20eba03..1c96672 100644 --- a/src/routes/examples/classic/+page.svelte +++ b/src/routes/examples/classic/+page.svelte @@ -1,7 +1,6 @@ @@ -50,4 +43,4 @@ Classic Example - svelte-echarts - + diff --git a/src/routes/examples/tree-shaking/+page.svelte b/src/routes/examples/tree-shaking/+page.svelte index 89d163c..8fd8063 100644 --- a/src/routes/examples/tree-shaking/+page.svelte +++ b/src/routes/examples/tree-shaking/+page.svelte @@ -1,7 +1,6 @@ @@ -69,4 +62,4 @@ Tree-shaking | svelte-echarts - + diff --git a/svelte.config.js b/svelte.config.js index ed7dad8..a400735 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -10,6 +10,10 @@ const config = { precompress: false, strict: false, }), + alias: { + 'svelte-echarts': './src/lib/svelte-echarts', + 'svelte-echarts/*': './src/lib/svelte-echarts/*', + }, }, } diff --git a/test/Chart.test.ts b/tests/Chart.test.ts similarity index 98% rename from test/Chart.test.ts rename to tests/Chart.test.ts index 725fd2e..ffdab3c 100644 --- a/test/Chart.test.ts +++ b/tests/Chart.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect, vi, beforeAll } from 'vitest' import { render, screen } from '@testing-library/svelte' import { queryHelpers } from '@testing-library/dom' -import { Chart } from '../src/lib' +import { Chart } from '$lib/svelte-echarts' import * as echarts from 'echarts/core' import type { EChartsOption } from 'echarts' import { BarChart } from 'echarts/charts' diff --git a/vite.config.ts b/vite.config.ts index 7808fb1..b24af62 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,6 +4,6 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ plugins: [sveltekit()], test: { - include: ['src/**/*.{test,spec}.{js,ts}'], + include: ['tests/**/*.{test,spec}.{js,ts,svelte}'], }, }) diff --git a/vitest.config.ts b/vitest.config.ts index 2c475b9..9e2982c 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -10,6 +10,7 @@ export default defineConfig({ resolve: { alias: { $lib: '/src/lib', + 'svelte-echarts': '/src/lib/svelte-echarts', }, }, })