Skip to content

Commit 3830685

Browse files
committed
test: configure ts loaders for rspack and webpack tests
1 parent 59aeea1 commit 3830685

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"serve": "^11.3.2",
7171
"source-map": "0.6.1",
7272
"tiny-glob": "^0.2.9",
73+
"ts-loader": "^9.5.2",
7374
"typescript": "^5.6.3",
7475
"typescript-eslint": "^8.13.0",
7576
"vite": "^5.4.10",

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,20 @@ export function resourcePlugin(
261261
return true
262262
}
263263

264-
const { filename } = parseVueRequest(id)
264+
const { filename, query } = parseVueRequest(id)
265+
266+
// include imports by custom-blocks
267+
let isResourcePath = resourcePaths.has(id)
268+
if (!isResourcePath && 'issuerPath' in query) {
269+
isResourcePath = resourcePaths.has(query.issuerPath!)
270+
}
271+
265272
return (
266273
filename.endsWith('vue') ||
267274
filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) ||
268275
(/\.(json5?|ya?ml)$/.test(filename) &&
269276
filter(filename) &&
270-
resourcePaths.has(id))
277+
isResourcePath)
271278
)
272279
},
273280

packages/unplugin-vue-i18n/test/utils.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,29 @@ export function bundleWebpackLike(
148148
{
149149
test: /\.vue$/,
150150
loader: vueLoaderPath
151-
}
151+
},
152+
framework === 'rspack'
153+
? {
154+
test: /\.ts$/,
155+
exclude: [/node_modules/],
156+
loader: 'builtin:swc-loader',
157+
options: {
158+
jsc: {
159+
parser: {
160+
syntax: 'typescript'
161+
}
162+
}
163+
},
164+
type: 'javascript/auto'
165+
}
166+
: {
167+
test: /\.tsx?$/,
168+
loader: 'ts-loader',
169+
exclude: /node_modules/,
170+
options: {
171+
transpileOnly: true
172+
}
173+
}
152174
]
153175
},
154176
plugins: [new VueLoader(), pluginFn({ include, ...options })]

pnpm-lock.yaml

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)