@wdio/browser-runner 8.29.0 → 8.29.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.
@@ -1 +1 @@
1
- {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../../src/vite/frameworks/fixtures/stencil.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAKR,kBAAkB,EACrB,MAAM,wBAAwB,CAAA;AAgB/B,UAAU,kBAAkB;IACxB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CA0HnE;AAsGD;;;;;GAKG;AACH,0BAAkB,SAAS;IACvB;;;OAGG;IACH,sBAAsB,IAAS;IAC/B;;;OAGG;IACH,sBAAsB,IAAS;IAC/B;;OAEG;IACH,iBAAiB,IAAS;IAM1B;;;;;OAKG;IACH,kBAAkB,IAAS;IAC3B;;;OAGG;IACH,oBAAoB,KAAS;IAC7B;;OAEG;IACH,OAAO,KAAS;IAEhB;;;;;OAKG;IACH,wBAAwB,KAA8C;CACzE;AASD;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,iBACrB,GAAG,kBACD,OAAO,KACxB,GAyBF,CAAA"}
1
+ {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../../src/vite/frameworks/fixtures/stencil.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAKR,kBAAkB,EACrB,MAAM,wBAAwB,CAAA;AAgB/B,UAAU,kBAAkB;IACxB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CA+HnE;AAsGD;;;;;GAKG;AACH,0BAAkB,SAAS;IACvB;;;OAGG;IACH,sBAAsB,IAAS;IAC/B;;;OAGG;IACH,sBAAsB,IAAS;IAC/B;;OAEG;IACH,iBAAiB,IAAS;IAM1B;;;;;OAKG;IACH,kBAAkB,IAAS;IAC3B;;;OAGG;IACH,oBAAoB,KAAS;IAC7B;;OAEG;IACH,OAAO,KAAS;IAEhB;;;;;OAKG;IACH,wBAAwB,KAA8C;CACzE;AASD;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,iBACrB,GAAG,kBACD,OAAO,KACxB,GAyBF,CAAA"}
@@ -1,4 +1,8 @@
1
1
  import { h } from '@stencil/core';
2
+ /**
3
+ * Emulate Node.js `nextTick` function in browser.
4
+ * This is used by Stencil.js internally.
5
+ */
2
6
  process.nextTick = (cb) => setTimeout(cb, 0);
3
7
  // @ts-expect-error
4
8
  window.React = {
@@ -47,7 +51,7 @@ export function render(opts) {
47
51
  win: win,
48
52
  doc: doc,
49
53
  body: stage,
50
- styles: styles
54
+ styles
51
55
  };
52
56
  const lazyBundles = opts.components.map((Cstr) => {
53
57
  // eslint-disable-next-line eqeqeq
@@ -72,6 +76,10 @@ export function render(opts) {
72
76
  }
73
77
  }
74
78
  registerModule(bundleId, Cstr);
79
+ /**
80
+ * Register the component as a custom element
81
+ */
82
+ customElements.define(Cstr.COMPILER_META.tagName, Cstr);
75
83
  const lazyBundleRuntimeMeta = formatLazyBundleRuntimeMeta(bundleId, [Cstr.COMPILER_META]);
76
84
  return lazyBundleRuntimeMeta;
77
85
  });
@@ -1 +1 @@
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
+ {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/stencil.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,MAAM,CAAA;AAahD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,oBAEhG;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,yBAwBvD"}
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import url from 'node:url';
3
- import { findStaticImports } from 'mlly';
3
+ import { findStaticImports, parseStaticImport } from 'mlly';
4
4
  import { hasFileByExtensions } from '../utils.js';
5
5
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
6
6
  const STENCIL_IMPORT = '@stencil/core';
@@ -29,7 +29,7 @@ export async function optimizeForStencil(rootDir) {
29
29
  return stencilOptimizations;
30
30
  }
31
31
  async function stencilVitePlugin(rootDir) {
32
- const { transpileSync } = await import('@stencil/core/compiler/stencil.js');
32
+ const { transpileSync, ts } = await import('@stencil/core/compiler/stencil.js');
33
33
  const stencilHelperPath = path.resolve(__dirname, 'fixtures', 'stencil.js');
34
34
  return {
35
35
  name: 'wdio-stencil',
@@ -40,39 +40,80 @@ async function stencilVitePlugin(rootDir) {
40
40
  }
41
41
  },
42
42
  transform: function (code, id) {
43
- const usesStencil = findStaticImports(code).some((imp) => imp.specifier === STENCIL_IMPORT);
44
- if (!usesStencil) {
43
+ const staticImports = findStaticImports(code);
44
+ const stencilImports = staticImports
45
+ .filter((imp) => imp.specifier === STENCIL_IMPORT)
46
+ .map((imp) => parseStaticImport(imp));
47
+ const isStencilComponent = stencilImports.some((imp) => 'Component' in (imp.namedImports || {}));
48
+ if (!isStencilComponent) {
45
49
  return { code };
46
50
  }
51
+ const tsCompilerOptions = getCompilerOptions(ts, rootDir);
47
52
  const opts = {
48
- componentExport: 'customelement',
53
+ componentExport: 'module',
49
54
  componentMetadata: 'compilerstatic',
50
- coreImportPath: '@stencil/core/internal/testing',
55
+ coreImportPath: '@stencil/core/internal/client',
51
56
  currentDirectory: rootDir,
57
+ file: path.basename(id),
52
58
  module: 'esm',
53
- proxy: null,
54
59
  sourceMap: 'inline',
55
60
  style: 'static',
61
+ proxy: 'defineproperty',
56
62
  styleImportData: 'queryparams',
57
- target: 'es2018',
58
63
  transformAliasedImportPaths: process.env.__STENCIL_TRANSPILE_PATHS__ === 'true',
64
+ target: tsCompilerOptions?.target || 'es2018',
65
+ paths: tsCompilerOptions?.paths,
66
+ baseUrl: tsCompilerOptions?.baseUrl,
59
67
  };
60
68
  const transpiledCode = transpileSync(code, opts);
69
+ /**
70
+ * StencilJS applies only a getter to the component without having a setter defined.
71
+ * This causes issue in the browser as there is a check that the setter is defined
72
+ * if the getter is defined. We can work around this by defining a setter.
73
+ */
74
+ let transformedCode = transpiledCode.code.replace('static get style()', 'static set style(_) {}\n static get style()');
75
+ /**
76
+ * StencilJS does not import the `h` or `Fragment` function by default. We need to add it so the user
77
+ * doesn't need to.
78
+ */
79
+ const hasRenderFunctionImport = stencilImports.some((imp) => 'h' in (imp.namedImports || {}));
80
+ if (!hasRenderFunctionImport) {
81
+ transformedCode = `import { h } from '@stencil/core';\n${transformedCode}`;
82
+ }
83
+ const hasFragmentImport = stencilImports.some((imp) => 'Fragment' in (imp.namedImports || {}));
84
+ if (!hasFragmentImport) {
85
+ transformedCode = `import { Fragment } from '@stencil/core';\n${transformedCode}`;
86
+ }
61
87
  return {
62
88
  ...transpiledCode,
63
- code: transpiledCode.code
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')
71
- // make sure that components are exported properly
72
- // StencilJS removes the export when componentExport is set to 'customelement'
73
- .replace('\nconst', '\nexport const'),
89
+ code: transformedCode,
74
90
  inputFilePath: id
75
91
  };
76
92
  }
77
93
  };
78
94
  }
95
+ let _tsCompilerOptions = null;
96
+ /**
97
+ * Read the TypeScript compiler configuration file from disk
98
+ * @param rootDir the location to search for the config file
99
+ * @returns the configuration, or `null` if the file cannot be found
100
+ */
101
+ function getCompilerOptions(ts, rootDir) {
102
+ if (_tsCompilerOptions) {
103
+ return _tsCompilerOptions;
104
+ }
105
+ if (typeof rootDir !== 'string') {
106
+ return null;
107
+ }
108
+ const tsconfigFilePath = ts.findConfigFile(rootDir, ts.sys.fileExists);
109
+ if (!tsconfigFilePath) {
110
+ return null;
111
+ }
112
+ const tsconfigResults = ts.readConfigFile(tsconfigFilePath, ts.sys.readFile);
113
+ if (tsconfigResults.error) {
114
+ throw new Error(tsconfigResults.error);
115
+ }
116
+ const parseResult = ts.parseJsonConfigFileContent(tsconfigResults.config, ts.sys, rootDir, undefined, tsconfigFilePath);
117
+ _tsCompilerOptions = parseResult.options;
118
+ return _tsCompilerOptions;
119
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/browser-runner",
3
- "version": "8.29.0",
3
+ "version": "8.29.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",
@@ -26,7 +26,10 @@
26
26
  "types": "./build/index.d.ts",
27
27
  "exports": {
28
28
  ".": "./build/index.js",
29
- "./package.json": "./package.json"
29
+ "./package.json": "./package.json",
30
+ "./stencil": {
31
+ "types": "./stencil/index.d.ts"
32
+ }
30
33
  },
31
34
  "typeScriptVersion": "3.8.3",
32
35
  "dependencies": {
@@ -34,14 +37,14 @@
34
37
  "@originjs/vite-plugin-commonjs": "^1.0.3",
35
38
  "@types/istanbul-lib-source-maps": "^4.0.1",
36
39
  "@vitest/spy": "^1.0.1",
37
- "@wdio/globals": "8.29.0",
38
- "@wdio/local-runner": "8.29.0",
40
+ "@wdio/globals": "8.29.1",
41
+ "@wdio/local-runner": "8.29.2",
39
42
  "@wdio/logger": "8.28.0",
40
- "@wdio/mocha-framework": "8.29.0",
43
+ "@wdio/mocha-framework": "8.29.1",
41
44
  "@wdio/protocols": "^8.24.12",
42
- "@wdio/runner": "8.29.0",
43
- "@wdio/types": "8.29.0",
44
- "@wdio/utils": "8.29.0",
45
+ "@wdio/runner": "8.29.2",
46
+ "@wdio/types": "8.29.1",
47
+ "@wdio/utils": "8.29.1",
45
48
  "deepmerge-ts": "^5.0.0",
46
49
  "expect": "^29.7.0",
47
50
  "expect-webdriverio": "^4.9.3",
@@ -59,8 +62,8 @@
59
62
  "vite": "~4.5.0",
60
63
  "vite-plugin-istanbul": "^5.0.0",
61
64
  "vite-plugin-top-level-await": "^1.3.0",
62
- "webdriver": "8.29.0",
63
- "webdriverio": "8.29.0"
65
+ "webdriver": "8.29.1",
66
+ "webdriverio": "8.29.1"
64
67
  },
65
68
  "scripts": {
66
69
  "prepare": "rimraf node_modules/@wdio/config node_modules/@wdio/repl node_modules/@wdio/utils"
@@ -68,5 +71,5 @@
68
71
  "publishConfig": {
69
72
  "access": "public"
70
73
  },
71
- "gitHead": "cfd2ee1a1b4c4dc5b399ada6c28e8ccfa90c3bf1"
74
+ "gitHead": "96b12554db896984d4c86f3ff1d85da36e04c4f3"
72
75
  }