@wdio/browser-runner 8.15.0 → 8.15.2

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.
@@ -12,7 +12,7 @@ export default async function updateViteConfig(options, config) {
12
12
  if (isTailwind) {
13
13
  Object.assign(optimizations, await optimizeForTailwindCSS(rootDir));
14
14
  }
15
- if (isUsingStencilJS(rootDir, options)) {
15
+ if (await isUsingStencilJS(rootDir, options)) {
16
16
  Object.assign(optimizations, await optimizeForStencil(rootDir));
17
17
  }
18
18
  return optimizations;
@@ -1,4 +1,4 @@
1
1
  import type { InlineConfig } from 'vite';
2
- export declare function isUsingStencilJS(rootDir: string, options: WebdriverIO.BrowserRunnerOptions): boolean;
2
+ export declare function isUsingStencilJS(rootDir: string, options: WebdriverIO.BrowserRunnerOptions): Promise<boolean>;
3
3
  export declare function optimizeForStencil(rootDir: string): Promise<InlineConfig>;
4
4
  //# sourceMappingURL=stencil.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/stencil.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,MAAM,CAAA;AAMhD,wBAAgB,gBAAgB,CAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,WAE3F;AAED,wBAAsB,kBAAkB,CAAE,OAAO,EAAE,MAAM,yBAiBxD"}
1
+ {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/stencil.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,MAAM,CAAA;AAOhD,wBAAsB,gBAAgB,CAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,oBAEjG;AAED,wBAAsB,kBAAkB,CAAE,OAAO,EAAE,MAAM,yBAwBxD"}
@@ -1,24 +1,31 @@
1
1
  import path from 'node:path';
2
2
  import url from 'node:url';
3
+ import { findStaticImports } from 'mlly';
3
4
  import { hasFileByExtensions } from '../utils.js';
4
5
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
5
- export function isUsingStencilJS(rootDir, options) {
6
- return Boolean(options.preset === 'stencil' || hasFileByExtensions(path.join(rootDir, 'stencil.config')));
6
+ const STENCIL_IMPORT = '@stencil/core';
7
+ export async function isUsingStencilJS(rootDir, options) {
8
+ return Boolean(options.preset === 'stencil' || await hasFileByExtensions(path.join(rootDir, 'stencil.config')));
7
9
  }
8
10
  export async function optimizeForStencil(rootDir) {
9
11
  const stencilConfig = await import(path.join(rootDir, 'stencil.config.ts')).catch(() => ({ config: {} }));
10
12
  const stencilPlugins = stencilConfig.config.plugins;
11
13
  const stencilOptimizations = {
12
- plugins: [await stencilVitePlugin(rootDir)]
14
+ plugins: [await stencilVitePlugin(rootDir)],
15
+ optimizeDeps: { include: [] }
13
16
  };
14
17
  if (stencilPlugins) {
15
18
  const esbuildPlugin = stencilPlugins.find((plugin) => plugin.name === 'esbuild-plugin');
16
19
  if (esbuildPlugin) {
17
- stencilOptimizations.optimizeDeps = {
18
- include: esbuildPlugin.options.include
19
- };
20
+ stencilOptimizations.optimizeDeps?.include?.push(...esbuildPlugin.options.include);
20
21
  }
21
22
  }
23
+ /**
24
+ * testing helper from the stencil core package is unfortunately exported as CJS
25
+ * module, in order to be able to use it in the browser we have to optimize it
26
+ * it to compile it to ESM
27
+ */
28
+ stencilOptimizations.optimizeDeps?.include?.push('@wdio/browser-runner/stencil > @stencil/core/internal/testing/index.js');
22
29
  return stencilOptimizations;
23
30
  }
24
31
  async function stencilVitePlugin(rootDir) {
@@ -33,7 +40,8 @@ async function stencilVitePlugin(rootDir) {
33
40
  }
34
41
  },
35
42
  transform: function (code, id) {
36
- if (!id.includes('StencilComponent.tsx')) {
43
+ const usesStencil = findStaticImports(code).some((imp) => imp.specifier === STENCIL_IMPORT);
44
+ if (!usesStencil) {
37
45
  return { code };
38
46
  }
39
47
  const opts = {
@@ -44,7 +52,7 @@ async function stencilVitePlugin(rootDir) {
44
52
  module: 'esm',
45
53
  proxy: null,
46
54
  sourceMap: 'inline',
47
- style: null,
55
+ style: 'static',
48
56
  styleImportData: 'queryparams',
49
57
  target: 'es2018',
50
58
  transformAliasedImportPaths: process.env.__STENCIL_TRANSPILE_PATHS__ === 'true',
@@ -53,8 +61,13 @@ async function stencilVitePlugin(rootDir) {
53
61
  return {
54
62
  ...transpiledCode,
55
63
  code: transpiledCode.code
56
- // HTMLElement gets imported from StencilJS, but we need to use the one from the browser
57
- .replace('extends HTMLElement {', 'extends window.HTMLElement {')
64
+ // HTMLElement gets imported from StencilJS but is undefined for some reasons
65
+ .replace('extends HTMLElement {',
66
+ // replace it with the original one
67
+ 'extends window.HTMLElement {' +
68
+ // and add a style setter so it won't throw when setting
69
+ // style properties
70
+ '\n\tstatic set style (ignore) {}\n')
58
71
  // make sure that components are exported properly
59
72
  // StencilJS removes the export when componentExport is set to 'customelement'
60
73
  .replace('\nconst', '\nexport const'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/browser-runner",
3
- "version": "8.15.0",
3
+ "version": "8.15.2",
4
4
  "description": "A WebdriverIO runner to run unit tests tests in the browser.",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-browser-runner",
@@ -52,6 +52,7 @@
52
52
  "istanbul-lib-report": "^3.0.0",
53
53
  "istanbul-lib-source-maps": "^4.0.1",
54
54
  "istanbul-reports": "^3.1.5",
55
+ "mlly": "^1.4.0",
55
56
  "modern-node-polyfills": "^1.0.0",
56
57
  "recast": "^0.23.2",
57
58
  "serialize-error": "^11.0.0",
@@ -73,5 +74,5 @@
73
74
  "@types/ws": "^8.5.4",
74
75
  "@wdio/runner": "8.15.0"
75
76
  },
76
- "gitHead": "78e199c5ffd74bdf3a5576952c3834c29afa989f"
77
+ "gitHead": "d123ee7129d2e5fc2427a8888408d7d967e015fe"
77
78
  }