Skip to content

Commit 255ae03

Browse files
committed
refactor: verbatimModuleSyntax option
1 parent 453f50b commit 255ae03

26 files changed

+107
-89
lines changed

packages/core-base/src/translate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
} from '@intlify/shared'
2020
import { isMessageAST } from './compilation'
2121
import {
22-
CoreContext,
2322
getAdditionalMeta,
2423
handleMissing,
2524
isAlmostSameLocale,
@@ -36,6 +35,7 @@ import { CoreWarnCodes, getWarnMessage } from './warnings'
3635
import type { AdditionalPayloads } from '@intlify/devtools-types'
3736
import type { CompileError, ResourceNode } from '@intlify/message-compiler'
3837
import type {
38+
CoreContext,
3939
CoreInternalContext,
4040
DefineCoreLocaleMessage,
4141
LocaleMessages,

packages/core-base/test/context.test-d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import {
2-
createCoreContext,
1+
import { createCoreContext } from '../src'
2+
3+
import type {
34
DateTimeFormat,
45
Locale,
56
LocaleDetector,
67
NumberFormat,
78
PickupFallbackLocales
89
} from '../src'
9-
1010
import type { MyDatetimeScehma, MyNumberSchema, ResourceSchema } from './schema'
1111

1212
// loose options

packages/core-base/test/fallbacker.test.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { createCoreContext as context, CoreContext } from '../src/context'
1+
import { createCoreContext as context } from '../src/context'
2+
import { CoreErrorCodes, errorMessages } from '../src/errors'
23
import {
34
fallbackWithLocaleChain,
45
fallbackWithSimple,
56
resolveLocale
67
} from '../src/fallbacker'
7-
import { errorMessages, CoreErrorCodes } from '../src/errors'
8-
import { LocaleDetector } from '@intlify/core-base'
8+
9+
import type { LocaleDetector } from '@intlify/core-base'
10+
import type { CoreContext } from '../src/context'
911

1012
describe('fallbackWithSimple', () => {
1113
let ctx: CoreContext<string>

packages/core-base/test/issues.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { NodeTypes } from '@intlify/message-compiler'
12
import { format } from '../src/format'
23
import { createMessageContext as context } from '../src/runtime'
34

4-
import { NodeTypes, ResourceNode } from '@intlify/message-compiler'
5+
import type { ResourceNode } from '@intlify/message-compiler'
56

67
describe('CVE-2024-52809', () => {
78
function attackGetter() {

packages/core-base/test/number.test.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ vi.mock('../src/intl', async () => {
2020
}
2121
})
2222

23-
import { createCoreContext as context, NOT_REOSLVED } from '../src/context'
24-
import { number } from '../src/number'
25-
import { CoreErrorCodes, errorMessages } from '../src/errors'
23+
import { compile } from '../src/compilation'
2624
import {
27-
registerMessageCompiler,
28-
registerLocaleFallbacker
25+
createCoreContext as context,
26+
NOT_REOSLVED,
27+
registerLocaleFallbacker,
28+
registerMessageCompiler
2929
} from '../src/context'
30-
import { compile } from '../src/compilation'
30+
import { CoreErrorCodes, errorMessages } from '../src/errors'
3131
import { fallbackWithLocaleChain } from '../src/fallbacker'
32-
import { NumberFormats } from '../src/types/index'
32+
import { number } from '../src/number'
33+
34+
import type { NumberFormats } from '../src/types/index'
3335

3436
type MyNumberSchema = {
3537
currency: {} // loose schema

packages/core-base/test/runtime.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MessageType } from '../src/runtime'
1+
import type { MessageType } from '../src/runtime'
22

33
/**
44
* Message Type

packages/format-explorer/vite.config.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { defineConfig } from 'vite'
21
import vue from '@vitejs/plugin-vue'
32
import { execaSync } from 'execa'
43
import path from 'node:path'
54
import { URL } from 'node:url'
5+
import { defineConfig } from 'vite'
66

77
const commit = execaSync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7)
88
console.log('commit', commit)
99

1010
const __dirname = path.dirname(new URL(import.meta.url).pathname)
1111

1212
// https://vitejs.dev/config/
13-
export default defineConfig({
13+
const config = defineConfig({
1414
define: {
1515
__COMMIT__: JSON.stringify(commit),
1616
__BROWSER__: false
@@ -25,3 +25,5 @@ export default defineConfig({
2525
},
2626
plugins: [vue()]
2727
})
28+
29+
export default config

packages/message-compiler/src/nodes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SourceLocation } from './location'
1+
import type { SourceLocation } from './location'
22

33
export const enum NodeTypes {
44
Resource, // 0

packages/vue-i18n-core/src/components/base.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { Composer } from '../composer'
2-
31
import type { Locale } from '@intlify/core-base'
2+
import type { Composer } from '../composer'
43
import type { I18nScope } from '../i18n'
54

65
export type ComponentI18nScope = Exclude<I18nScope, 'local'>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
export { BaseFormatProps, ComponentI18nScope } from './base'
2-
export { DatetimeFormat, DatetimeFormatProps, I18nD } from './DatetimeFormat'
3-
export { FormattableProps } from './formatRenderer'
4-
export { I18nN, NumberFormat, NumberFormatProps } from './NumberFormat'
5-
export { I18nT, Translation, TranslationProps } from './Translation'
1+
export { DatetimeFormat, I18nD } from './DatetimeFormat'
2+
export { I18nN, NumberFormat } from './NumberFormat'
3+
export { I18nT, Translation } from './Translation'
4+
5+
export type { BaseFormatProps, ComponentI18nScope } from './base'
6+
export type { DatetimeFormatProps } from './DatetimeFormat'
7+
export type { FormattableProps } from './formatRenderer'
8+
export type { NumberFormatProps } from './NumberFormat'
9+
export type { TranslationProps } from './Translation'

packages/vue-i18n-core/src/composer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import {
33
DEFAULT_LOCALE,
44
MISSING_RESOLVE_VALUE,
5-
MessageFunction,
65
NOT_REOSLVED,
76
clearDateTimeFormat,
87
clearNumberFormat,
@@ -80,6 +79,7 @@ import type {
8079
LocaleMessages,
8180
LocaleParams,
8281
MessageCompiler,
82+
MessageFunction,
8383
MessageFunctions,
8484
MessageProcessor,
8585
MessageResolver,

packages/vue-i18n-core/src/devtools.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import {
66
isObject,
77
isString
88
} from '@intlify/shared'
9-
import {
10-
ComponentTreeNode,
11-
Hooks,
12-
setupDevtoolsPlugin
13-
} from '@vue/devtools-api'
9+
import { setupDevtoolsPlugin } from '@vue/devtools-api'
1410

1511
import type {
1612
VueDevToolsIDs,
@@ -19,9 +15,11 @@ import type {
1915
} from '@intlify/devtools-types'
2016
import type {
2117
ComponentStateBase,
18+
ComponentTreeNode,
2219
CustomInspectorState,
2320
DevtoolsPluginApi,
2421
HookPayloads,
22+
Hooks,
2523
InspectedComponentData
2624
} from '@vue/devtools-api'
2725
import type { App, ComponentInternalInstance } from 'vue'

packages/vue-i18n-core/src/i18n.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
warnOnce
1010
} from '@intlify/shared'
1111
import {
12-
InjectionKey,
1312
effectScope,
1413
getCurrentInstance,
1514
inject,
@@ -42,7 +41,12 @@ import type {
4241
VueDevToolsEmitter,
4342
VueDevToolsEmitterEvents
4443
} from '@intlify/devtools-types'
45-
import type { App, ComponentInternalInstance, EffectScope } from 'vue'
44+
import type {
45+
App,
46+
ComponentInternalInstance,
47+
EffectScope,
48+
InjectionKey
49+
} from 'vue'
4650
import type {
4751
Composer,
4852
ComposerInternalOptions,

packages/vue-i18n-core/src/legacy.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
isRegExp,
1010
isString
1111
} from '@intlify/shared'
12-
import { createComposer, DefineLocaleMessage } from './composer'
12+
import { createComposer } from './composer'
1313
import { DisableEmitter, EnableEmitter } from './symbols'
1414

1515
import type {
@@ -55,6 +55,7 @@ import type {
5555
DefaultLocaleMessageSchema,
5656
DefaultNumberFormatSchema,
5757
DefineDateTimeFormat,
58+
DefineLocaleMessage,
5859
DefineNumberFormat,
5960
MissingHandler,
6061
VueMessageType

packages/vue-i18n-core/test/components/DatetimeFormat.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import {
1010
registerMessageResolver,
1111
resolveValue
1212
} from '@intlify/core-base'
13-
import { defineComponent, h, SetupContext, VNodeChild } from 'vue'
13+
import { defineComponent, h } from 'vue'
1414
import { createI18n } from '../../src/index'
1515
import { mount } from '../helper'
1616

17+
import type { SetupContext, VNodeChild } from 'vue'
1718
import type { IntlDateTimeFormats } from '../../src/index'
1819

1920
const datetimeFormats: IntlDateTimeFormats = {

packages/vue-i18n-core/test/components/NumberFormat.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import {
1010
registerMessageResolver,
1111
resolveValue
1212
} from '@intlify/core-base'
13-
import { defineComponent, h, SetupContext, VNodeChild } from 'vue'
13+
import { defineComponent, h } from 'vue'
1414
import { createI18n } from '../../src/index'
1515
import { mount } from '../helper'
1616

17+
import type { SetupContext, VNodeChild } from 'vue'
1718
import type { IntlNumberFormats } from '../../src/index'
1819

1920
const numberFormats: IntlNumberFormats = {

packages/vue-i18n-core/test/components/Translation.test.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,12 @@ import {
1010
registerMessageResolver,
1111
resolveValue
1212
} from '@intlify/core-base'
13-
import {
14-
defineComponent,
15-
h,
16-
nextTick,
17-
ref,
18-
SetupContext,
19-
VNodeChild
20-
} from 'vue'
13+
import { defineComponent, h, nextTick, ref } from 'vue'
2114
import { createI18n, useI18n } from '../../src/index'
2215
import { mount } from '../helper'
2316

2417
import type { Path, PathValue } from '@intlify/core-base'
25-
import type { Ref } from 'vue'
18+
import type { Ref, SetupContext, VNodeChild } from 'vue'
2619

2720
const messages = {
2821
en: {

packages/vue-i18n-core/test/composer.test.ts

+21-18
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,44 @@
55

66
// utils
77
import * as shared from '@intlify/shared'
8+
import { pluralRules as _pluralRules } from './helper'
89
vi.mock('@intlify/shared', async () => {
910
const actual = await vi.importActual<object>('@intlify/shared')
1011
return {
1112
...actual,
1213
warn: vi.fn()
1314
}
1415
})
15-
import { pluralRules as _pluralRules } from './helper'
1616

1717
import {
18-
createComposer,
19-
MissingHandler,
20-
ComposerOptions,
21-
VueMessageType
22-
} from '../src/composer'
18+
compile,
19+
fallbackWithLocaleChain,
20+
registerLocaleFallbacker,
21+
registerMessageCompiler,
22+
registerMessageResolver,
23+
resolveValue
24+
} from '@intlify/core-base'
25+
import { createVNode, nextTick, Text, watch, watchEffect } from 'vue'
26+
import { createComposer } from '../src/composer'
2327
import {
24-
TranslateVNodeSymbol,
28+
DatetimePartsSymbol,
2529
NumberPartsSymbol,
26-
DatetimePartsSymbol
30+
TranslateVNodeSymbol
2731
} from '../src/symbols'
2832
import { getWarnMessage, I18nWarnCodes } from '../src/warnings'
29-
import { watch, watchEffect, nextTick, Text, createVNode } from 'vue'
30-
import {
33+
34+
import type {
3135
Locale,
32-
compile,
33-
registerMessageCompiler,
34-
resolveValue,
35-
registerMessageResolver,
36-
fallbackWithLocaleChain,
37-
registerLocaleFallbacker,
3836
MessageContext,
37+
MessageFunction,
3938
Path,
40-
PathValue,
41-
MessageFunction
39+
PathValue
4240
} from '@intlify/core-base'
41+
import type {
42+
ComposerOptions,
43+
MissingHandler,
44+
VueMessageType
45+
} from '../src/composer'
4346

4447
beforeEach(() => {
4548
registerMessageCompiler(compile)

packages/vue-i18n-core/test/helper.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1+
import { assign, isBoolean, isPlainObject } from '@intlify/shared'
2+
import { compile } from '@vue/compiler-dom'
3+
import * as runtimeDom from 'vue'
14
import {
25
createApp,
36
defineComponent,
47
h,
5-
ComponentPublicInstance,
6-
reactive,
78
nextTick,
8-
ComponentObjectPropsOptions,
9-
App,
10-
VNode,
11-
shallowRef,
129
onErrorCaptured,
13-
ComponentOptions
10+
reactive,
11+
shallowRef
1412
} from 'vue'
15-
import { compile } from '@vue/compiler-dom'
16-
import * as runtimeDom from 'vue'
17-
import { isBoolean, isPlainObject, assign } from '@intlify/shared'
18-
import { I18n } from '../src/i18n'
1913

14+
import type {
15+
App,
16+
ComponentObjectPropsOptions,
17+
ComponentOptions,
18+
ComponentPublicInstance,
19+
VNode
20+
} from 'vue'
21+
import type { I18n } from '../src/i18n'
2022
import type { I18nPluginOptions } from '../src/plugin/types'
2123

2224
export interface MountOptions {

packages/vue-i18n-core/test/i18n.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@ import {
2424
} from '@intlify/core-base'
2525
import { createEmitter } from '@intlify/shared'
2626
import {
27-
ComponentOptions,
2827
defineComponent,
2928
defineCustomElement,
3029
getCurrentInstance,
3130
h,
3231
nextTick,
3332
ref
3433
} from 'vue'
35-
import { Composer } from '../src/composer'
3634
import { errorMessages, I18nErrorCodes } from '../src/errors'
3735
import { createI18n, useI18n } from '../src/i18n'
3836
import { pluralRules as _pluralRules, mount, randStr } from './helper'
3937

4038
import type { IntlifyDevToolsEmitterHooks } from '@intlify/devtools-types'
41-
import type { App } from 'vue'
39+
import type { App, ComponentOptions } from 'vue'
40+
import type { Composer } from '../src/composer'
4241
import type { I18n } from '../src/i18n'
4342
import type { VueI18n } from '../src/legacy'
4443
/* eslint-disable @typescript-eslint/no-explicit-any */

0 commit comments

Comments
 (0)