@stencil/vitest 1.11.4 → 1.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin.d.ts +3 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +18 -14
- package/package.json +2 -2
package/dist/plugin.d.ts
CHANGED
|
@@ -33,5 +33,7 @@ import type { Plugin } from 'vitest/config';
|
|
|
33
33
|
* @param opts Optional configuration for the plugin
|
|
34
34
|
* @returns a Vite plugin configuration object
|
|
35
35
|
*/
|
|
36
|
-
export declare function stencilVitestPlugin(
|
|
36
|
+
export declare function stencilVitestPlugin(opts?: {
|
|
37
|
+
css?: boolean;
|
|
38
|
+
}): Plugin;
|
|
37
39
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAgGxE"}
|
package/dist/plugin.js
CHANGED
|
@@ -35,7 +35,7 @@ import { dirname, resolve } from 'node:path';
|
|
|
35
35
|
* @param opts Optional configuration for the plugin
|
|
36
36
|
* @returns a Vite plugin configuration object
|
|
37
37
|
*/
|
|
38
|
-
export function stencilVitestPlugin() {
|
|
38
|
+
export function stencilVitestPlugin(opts = {}) {
|
|
39
39
|
return {
|
|
40
40
|
name: 'stencil-vitest-transform',
|
|
41
41
|
enforce: 'pre',
|
|
@@ -43,9 +43,14 @@ export function stencilVitestPlugin() {
|
|
|
43
43
|
if (id.includes('.css') && id.includes('tag=')) {
|
|
44
44
|
const [relPath] = id.split('?');
|
|
45
45
|
const query = id.slice(id.indexOf('?'));
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const realImporter = importer?.startsWith('\0stencil-style:')
|
|
47
|
+
? importer.slice('\0stencil-style:'.length).split('?')[0] + '.css'
|
|
48
|
+
: importer;
|
|
49
|
+
// Resolve bare specifiers from node_modules, otherwise resolve relative to importer
|
|
50
|
+
const resolved = !relPath.startsWith('.') && !relPath.startsWith('/')
|
|
51
|
+
? resolve(process.cwd(), 'node_modules', relPath.replace(/^~/, ''))
|
|
52
|
+
: resolve(dirname(realImporter), relPath);
|
|
53
|
+
return '\0stencil-style:' + resolved.replace(/\.css$/, '') + (query || '');
|
|
49
54
|
}
|
|
50
55
|
return null;
|
|
51
56
|
},
|
|
@@ -59,15 +64,13 @@ export function stencilVitestPlugin() {
|
|
|
59
64
|
},
|
|
60
65
|
async transform(code, id) {
|
|
61
66
|
if (id.startsWith('\0stencil-style:')) {
|
|
62
|
-
// Reconstruct the original .css path for Stencil's transpiler (it uses extension to detect file type)
|
|
63
67
|
const pathWithoutPrefix = id.slice('\0stencil-style:'.length);
|
|
64
68
|
const [basePath, query] = pathWithoutPrefix.split('?');
|
|
65
69
|
const originalPath = basePath + '.css' + (query ? '?' + query : '');
|
|
66
|
-
const result = await transpile(code, {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
70
|
+
const result = await transpile(code, {
|
|
71
|
+
file: originalPath,
|
|
72
|
+
});
|
|
73
|
+
return { code: result.code, map: null };
|
|
71
74
|
}
|
|
72
75
|
// Only transform .tsx files
|
|
73
76
|
if (!id.endsWith('.tsx')) {
|
|
@@ -90,14 +93,15 @@ export function stencilVitestPlugin() {
|
|
|
90
93
|
// 'customelement' appends a customElements.define() call so the component
|
|
91
94
|
// self-registers the moment this module is imported — no loader needed.
|
|
92
95
|
componentExport: 'customelement',
|
|
93
|
-
componentMetadata: '
|
|
96
|
+
componentMetadata: 'runtimestatic',
|
|
94
97
|
currentDirectory: process.cwd(),
|
|
95
98
|
module: 'esm',
|
|
96
99
|
proxy: null,
|
|
97
100
|
sourceMap: false,
|
|
98
|
-
style: 'static',
|
|
99
|
-
styleImportData: 'queryparams',
|
|
100
|
-
target: '
|
|
101
|
+
style: opts.css ? 'static' : null,
|
|
102
|
+
styleImportData: opts.css ? 'queryparams' : null,
|
|
103
|
+
target: 'es2017',
|
|
104
|
+
// Don't rewrite import paths — let Vite handle resolution via aliases
|
|
101
105
|
transformAliasedImportPaths: false,
|
|
102
106
|
});
|
|
103
107
|
const errors = result.diagnostics?.filter((d) => d.level === 'error') ?? [];
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/stenciljs/vitest"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.11.
|
|
7
|
+
"version": "1.11.6",
|
|
8
8
|
"description": "First-class testing utilities for Stencil design systems with Vitest",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"dependencies": {
|
|
105
105
|
"jiti": "^2.6.1",
|
|
106
106
|
"local-pkg": "^1.1.2",
|
|
107
|
-
"vitest-environment-stencil": "1.11.
|
|
107
|
+
"vitest-environment-stencil": "1.11.6"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
110
|
"@eslint/js": "^9.39.2",
|