Skip to content

Commit ef364a3

Browse files
committed
perf!: use .n.ts
1 parent bc0474e commit ef364a3

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

packages/vue-note/src/vite/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function VueNote(): PluginOption {
1515
const ssr = opt?.ssr === true
1616
const { filename, query } = parseQuery(id)
1717

18-
if (!filename.endsWith('.ts'))
18+
if (!filename.endsWith('.n.ts'))
1919
return
2020

2121
const { result, cache } = await transform(
@@ -51,7 +51,7 @@ export function VueNote(): PluginOption {
5151
)
5252
: []
5353
),
54-
/\.ts$/,
54+
/\.n\.ts$/,
5555
]
5656

5757
return config

packages/vue-note/src/vite/transform.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,31 @@ export default defineCommentComponent(() => {
3636

3737
describe('production', () => {
3838
it('should work in production', async () => {
39-
expect(await transform(testScript, `test.ts`, createMockContext(), {}, false, createMockServer(true, false))).toMatchSnapshot()
39+
expect(await transform(testScript, `test.n.ts`, createMockContext(), {}, false, createMockServer(true, false))).toMatchSnapshot()
4040
})
4141

4242
it('should work with style imports', async () => {
43-
expect(await transform(`import 'style.css'; \n ${testScript}`, `test.ts`, createMockContext(), {}, false, createMockServer(true, false))).toMatchSnapshot()
43+
expect(await transform(`import 'style.css'; \n ${testScript}`, `test.n.ts`, createMockContext(), {}, false, createMockServer(true, false))).toMatchSnapshot()
4444
})
4545
})
4646

4747
describe('development', () => {
4848
it('should work and inject HMR code', async () => {
49-
expect(await transform(testScript, `test.ts`, createMockContext(), {}, false, createMockServer(false, true))).toMatchSnapshot()
49+
expect(await transform(testScript, `test.n.ts`, createMockContext(), {}, false, createMockServer(false, true))).toMatchSnapshot()
5050
})
5151

5252
it('should detect script change and inject HMR code', async () => {
53-
const first = await transform(testScript, `test.ts`, createMockContext(), {}, false, createMockServer(false, true))
53+
const first = await transform(testScript, `test.n.ts`, createMockContext(), {}, false, createMockServer(false, true))
5454

55-
const second = await transform(testScript.replace('Good Morning', 'Good Afternoon'), `test.ts`, createMockContext(), {}, false, createMockServer(false, true), first.cache)
55+
const second = await transform(testScript.replace('Good Morning', 'Good Afternoon'), `test.n.ts`, createMockContext(), {}, false, createMockServer(false, true), first.cache)
5656
expect(second.result?.code).toContain('const __VUE_HMR_SCRIPT_CHANGED__ = true;')
5757
expect(second.result?.code).not.toContain('changed: true,')
5858
})
5959

6060
it('should detect template change and inject HMR code', async () => {
61-
const first = await transform(testScript, `test.ts`, createMockContext(), {}, false, createMockServer(false, true))
61+
const first = await transform(testScript, `test.n.ts`, createMockContext(), {}, false, createMockServer(false, true))
6262

63-
const second = await transform(testScript.replace('Hello World', 'Hello Vue Note'), `test.ts`, createMockContext(), {}, false, createMockServer(false, true), first.cache)
63+
const second = await transform(testScript.replace('Hello World', 'Hello Vue Note'), `test.n.ts`, createMockContext(), {}, false, createMockServer(false, true), first.cache)
6464
expect(second.result?.code).not.toContain('const __VUE_HMR_SCRIPT_CHANGED__ = true;')
6565
expect(second.result?.code).toContain('changed: true,')
6666
})

playground/src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
2-
import HmrTest from './components/hmrTest'
3-
import AppHome from './components/testPart'
2+
import HmrTest from './components/hmrTest.n'
3+
import AppHome from './components/testPart.n'
44
</script>
55

66
<template>
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)