Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: __name is not defined #763

Merged
merged 52 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
1eb79bc
test: add nested function exec test
goosewobbler Sep 8, 2024
76c97be
chore: update deps
goosewobbler Sep 8, 2024
df0f5d7
test: add regular func test
goosewobbler Sep 8, 2024
45f6270
chore: delete override
goosewobbler Sep 8, 2024
8876f0f
chore(linting): fix import-x issues
goosewobbler Sep 8, 2024
a3ad311
chore: reorder imports
goosewobbler Sep 8, 2024
f3d866c
test(e2e): add JS specs
goosewobbler Sep 9, 2024
4e5b240
debug: run js specs first
goosewobbler Sep 9, 2024
81fbdd7
chore(linting): exempt JS E2E files for now
goosewobbler Sep 9, 2024
3d616fb
fix: update type imports
goosewobbler Sep 9, 2024
72c4535
fix: add `__name` to preload
goosewobbler Sep 9, 2024
d30314c
refactor: convert TS files using rollup
goosewobbler Sep 9, 2024
d70ffcc
fix: update browser type
goosewobbler Sep 9, 2024
7ee90e8
fix: await element
goosewobbler Sep 9, 2024
480073d
fix: update rollup conf
goosewobbler Sep 9, 2024
acdc2d2
fix: don't emit type declarations
goosewobbler Sep 9, 2024
4d085c5
fix: correct config dir
goosewobbler Sep 9, 2024
88dd05f
debug: remove `--only`
goosewobbler Sep 9, 2024
ceb08fe
fix: limit execution of dependent tasks
goosewobbler Sep 9, 2024
bda8179
chore: use defineConfig for rollup confs
goosewobbler Sep 9, 2024
c1c1969
chore(types): fix reference path
goosewobbler Sep 9, 2024
de6a8f5
chore: reorder imports
goosewobbler Sep 9, 2024
d65efb2
fix(linting): use correct parserOptions, disable `import-x/named` for…
goosewobbler Sep 9, 2024
d7c4df7
chore(typing): use unknown instead of any
goosewobbler Sep 9, 2024
b52d881
chore: disable sourceMaps
goosewobbler Sep 9, 2024
97a9471
chore(linting): remove `any`
goosewobbler Sep 9, 2024
10614a0
chore: add comments
goosewobbler Sep 9, 2024
eff62c7
chore: remove `typeScriptVersion`
goosewobbler Sep 10, 2024
84b971b
chore(linting): remove ignored files, update ES version
goosewobbler Sep 11, 2024
b2e0567
chore: update ES targets
goosewobbler Sep 11, 2024
4a83fac
chore: update ES version, add vitest/jsdom types
goosewobbler Sep 11, 2024
e3274e1
chore: delete unused deps and config including rollup
goosewobbler Sep 11, 2024
2d5879e
chore: update pnpm, remove unused jsdom
goosewobbler Sep 11, 2024
82d76d1
chore: remove unused deps, pin `@electron/asar`to work around b0rkage
goosewobbler Sep 11, 2024
c390e9d
chore: update deps, fix CJS types masquerading as ESM
goosewobbler Sep 11, 2024
f7cc6cc
chore: update deps, remove unused
goosewobbler Sep 11, 2024
5ed876b
chore: update lockfile
goosewobbler Sep 11, 2024
8024a07
chore: specify correct rollup config
goosewobbler Sep 11, 2024
b0df116
chore: standardise tsconfig
goosewobbler Sep 11, 2024
6254ef2
chore: update ES version
goosewobbler Sep 11, 2024
c6acaf8
chore: add extension to import
goosewobbler Sep 11, 2024
6c2d763
chore: remove unused template str
goosewobbler Sep 11, 2024
16bfd5b
refactor: standardise preloads for ESM examples
goosewobbler Sep 11, 2024
8bddfe7
refactor: instantiate plugins once
goosewobbler Sep 11, 2024
4895655
chore: rename plugin import
goosewobbler Sep 11, 2024
7cfe7aa
chore: use top level await
goosewobbler Sep 11, 2024
fc3159f
chore: improve verbiage
goosewobbler Sep 11, 2024
9102cd3
chore: update lockfile
goosewobbler Sep 11, 2024
c99d3cf
chore: fix include
goosewobbler Sep 11, 2024
700b2ba
chore: slim down tsconfigs
goosewobbler Sep 11, 2024
a6e6be4
fix: add workaround for rollup ts plugin overwriting module value
goosewobbler Sep 11, 2024
5eabaaf
chore: update `@electron/packager`, remove asar version pin workaround
goosewobbler Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions apps/builder-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,16 @@
"wdio-electron-service": "workspace:*"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.1",
"@types/node": "^20.16.1",
"@wdio/cli": "^9.0.7",
"@wdio/globals": "^9.0.7",
"@wdio/local-runner": "^9.0.7",
"@wdio/mocha-framework": "^9.0.6",
"cross-env": "^7.0.3",
"electron": "^32.0.1",
"electron-builder": "^25.0.1",
"global-jsdom": "^24.0.0",
"jsdom": "^24.1.1",
"rollup": "^4.21.0",
"ts-loader": "^9.4.4",
"tsx": "^4.17.0",
"typescript": "^5.5.4",
"webdriverio": "^9.0.7"
},
"peerDependencies": {
"typescript": "5.2.2"
"@wdio/cli": "^9.0.9",
"@wdio/globals": "^9.0.9",
"@wdio/local-runner": "^9.0.9",
"@wdio/mocha-framework": "^9.0.8",
"electron": "^32.0.2",
"electron-builder": "^25.0.5",
"tsx": "^4.19.0",
"typescript": "^5.6.2",
"webdriverio": "^9.0.9"
},
"build": {
"asar": true,
Expand Down
15 changes: 0 additions & 15 deletions apps/builder-cjs/rollup.config.js

This file was deleted.

3 changes: 1 addition & 2 deletions apps/builder-cjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.base.cjs.json",
"compilerOptions": {
"target": "ESNext",
"types": ["node"],
"types": [],
"typeRoots": ["./node_modules", "./node_modules/@types", "../../@types"],
"outDir": "dist"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/builder-esm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

An ESM project for a minimal Electron app, designed to provide E2E testing for `wdio-electron-service`.

The app is built using `electron-builder` and the preload script is bundled as CJS, this is to work around a limitation of Electron's ESM support.
The app is built using `electron-builder` and is not bundled.
31 changes: 10 additions & 21 deletions apps/builder-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "module",
"scripts": {
"build": "pnpm build:bundle && pnpm build:package",
"build:bundle": "tsc --outDir dist",
"build:bundle": "tsc",
"build:package": "cp ./src/index.html ./dist && electron-builder -p never",
"build:package:mac-universal": "cp ./src/index.html ./dist && electron-builder -p never -m --universal",
"build:mac-universal": "pnpm build:bundle && pnpm build:package:mac-universal",
Expand All @@ -18,27 +18,16 @@
"wdio-electron-service": "workspace:*"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.1",
"@types/node": "^20.16.1",
"@wdio/cli": "^9.0.7",
"@wdio/globals": "^9.0.7",
"@wdio/local-runner": "^9.0.7",
"@wdio/mocha-framework": "^9.0.6",
"cross-env": "^7.0.3",
"electron": "^32.0.1",
"electron-builder": "^25.0.1",
"global-jsdom": "^24.0.0",
"jsdom": "^24.1.1",
"rollup": "^4.21.0",
"ts-loader": "^9.4.4",
"tsx": "^4.17.0",
"typescript": "^5.5.4",
"webdriverio": "^9.0.7"
},
"peerDependencies": {
"typescript": "5.2.2"
"@wdio/cli": "^9.0.9",
"@wdio/globals": "^9.0.9",
"@wdio/local-runner": "^9.0.9",
"@wdio/mocha-framework": "^9.0.8",
"electron": "^32.0.2",
"electron-builder": "^25.0.5",
"tsx": "^4.19.0",
"typescript": "^5.6.2",
"webdriverio": "^9.0.9"
},
"build": {
"asar": true,
Expand Down
14 changes: 0 additions & 14 deletions apps/builder-esm/rollup.config.js

This file was deleted.

9 changes: 4 additions & 5 deletions apps/builder-esm/src/preload.cts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { contextBridge, ipcRenderer } from 'electron';

async function init() {
(async () => {
// util.js is an ESM module so we need to use dynamic import
const { isTest } = await import('./util.js');

if (isTest) {
import('wdio-electron-service/preload');
require('wdio-electron-service/preload');
}

const validChannels = ['increase-window-size', 'decrease-window-size'];
Expand All @@ -15,6 +16,4 @@ async function init() {
contextBridge.exposeInMainWorld('api', {
invoke,
});
}

init();
})();
6 changes: 3 additions & 3 deletions apps/builder-esm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ESNext",
"types": ["node"],
"typeRoots": ["./node_modules", "./node_modules/@types", "../../@types"]
"types": [],
"typeRoots": ["./node_modules", "./node_modules/@types", "../../@types"],
"outDir": "dist"
},
"include": ["src/*.ts", "src/preload.cts"],
"exclude": ["node_modules"]
Expand Down
26 changes: 10 additions & 16 deletions apps/forge-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,16 @@
"@electron-forge/cli": "^7.4.0",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.16.1",
"@wdio/cli": "^9.0.7",
"@wdio/globals": "^9.0.7",
"@wdio/local-runner": "^9.0.7",
"@wdio/mocha-framework": "^9.0.6",
"cross-env": "^7.0.3",
"electron": "^32.0.1",
"global-jsdom": "^24.0.0",
"jsdom": "^24.1.1",
"rollup": "^4.21.0",
"ts-loader": "^9.4.4",
"tsx": "^4.17.0",
"typescript": "^5.5.4",
"webdriverio": "^9.0.7"
},
"peerDependencies": {
"typescript": "5.2.2"
"@wdio/cli": "^9.0.9",
"@wdio/globals": "^9.0.9",
"@wdio/local-runner": "^9.0.9",
"@wdio/mocha-framework": "^9.0.8",
"electron": "^32.0.2",
"rollup": "^4.21.2",
"tsx": "^4.19.0",
"typescript": "^5.6.2",
"webdriverio": "^9.0.9"
}
}
5 changes: 3 additions & 2 deletions apps/forge-cjs/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { defineConfig } from 'rollup';

export default [
export default defineConfig([
{
input: 'dist/preload.js',
output: {
Expand All @@ -22,4 +23,4 @@ export default [
plugins: [nodeResolve(), commonjs()],
external: ['electron'],
},
];
]);
2 changes: 1 addition & 1 deletion apps/forge-cjs/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app, BrowserWindow, ipcMain } from 'electron';
import { isTest } from './util';
import { isTest } from './util.js';

if (isTest) {
require('wdio-electron-service/main');
Expand Down
2 changes: 1 addition & 1 deletion apps/forge-cjs/src/preload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { contextBridge, ipcRenderer } from 'electron';
import { isTest } from './util';
import { isTest } from './util.js';

if (isTest) {
require('wdio-electron-service/preload');
Expand Down
2 changes: 0 additions & 2 deletions apps/forge-cjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "../../tsconfig.base.cjs.json",
"compilerOptions": {
"target": "ES2022",
"baseUrl": ".",
"types": [],
"typeRoots": ["./node_modules", "./node_modules/@types", "../../node_modules/@types", "../../@types"],
"outDir": "dist"
Expand Down
26 changes: 10 additions & 16 deletions apps/forge-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,16 @@
"@electron-forge/cli": "^7.4.0",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.16.1",
"@wdio/cli": "^9.0.7",
"@wdio/globals": "^9.0.7",
"@wdio/local-runner": "^9.0.7",
"@wdio/mocha-framework": "^9.0.6",
"cross-env": "^7.0.3",
"electron": "^32.0.1",
"global-jsdom": "^24.0.0",
"jsdom": "^24.1.1",
"rollup": "^4.21.0",
"ts-loader": "^9.4.4",
"tsx": "^4.17.0",
"typescript": "^5.5.4",
"webdriverio": "^9.0.7"
},
"peerDependencies": {
"typescript": "5.2.2"
"@wdio/cli": "^9.0.9",
"@wdio/globals": "^9.0.9",
"@wdio/local-runner": "^9.0.9",
"@wdio/mocha-framework": "^9.0.8",
"electron": "^32.0.2",
"rollup": "^4.21.2",
"tsx": "^4.19.0",
"typescript": "^5.6.2",
"webdriverio": "^9.0.9"
}
}
14 changes: 9 additions & 5 deletions apps/forge-esm/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { defineConfig } from 'rollup';

export default [
const nodeResolvePlugin = nodeResolve();
const commonjsPlugin = commonjs();

export default defineConfig([
{
input: 'dist/preload.js',
input: 'dist/preload.cjs',
output: {
file: 'dist/preload.bundle.cjs',
inlineDynamicImports: true,
format: 'cjs',
},
plugins: [nodeResolve(), commonjs()],
plugins: [nodeResolvePlugin, commonjsPlugin],
external: ['electron'],
},
{
Expand All @@ -19,7 +23,7 @@ export default [
inlineDynamicImports: true,
format: 'esm',
},
plugins: [nodeResolve()],
plugins: [nodeResolvePlugin],
external: ['electron'],
},
];
]);
3 changes: 1 addition & 2 deletions apps/forge-esm/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { app, BrowserWindow, ipcMain } from 'electron';
import { isTest } from './util.js';

if (isTest) {
import('wdio-electron-service/main');
await import('wdio-electron-service/main');
}

const appPath = app.getAppPath();

const appRootPath = `${appPath}/dist`;
let mainWindow: BrowserWindow;

Expand Down
19 changes: 19 additions & 0 deletions apps/forge-esm/src/preload.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { contextBridge, ipcRenderer } from 'electron';

(async () => {
// util.js is an ESM module so we need to use dynamic import
const { isTest } = await import('./util.js');

if (isTest) {
require('wdio-electron-service/preload');
}

const validChannels = ['increase-window-size', 'decrease-window-size'];

const invoke = (channel: string, ...data: unknown[]) =>
validChannels.includes(channel) ? ipcRenderer.invoke(channel, data) : Promise.reject();

contextBridge.exposeInMainWorld('api', {
invoke,
});
})();
15 changes: 0 additions & 15 deletions apps/forge-esm/src/preload.ts

This file was deleted.

5 changes: 2 additions & 3 deletions apps/forge-esm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ESNext",
"types": ["node"],
"types": [],
"typeRoots": ["./node_modules", "./node_modules/@types", "../../node_modules/@types", "../../@types"],
"outDir": "dist"
},
"exclude": ["node_modules"],
"include": ["src/*.ts"]
"include": ["src/*.ts", "src/preload.cts"]
}
26 changes: 10 additions & 16 deletions apps/no-binary-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.16.1",
"@wdio/cli": "^9.0.7",
"@wdio/globals": "^9.0.7",
"@wdio/local-runner": "^9.0.7",
"@wdio/mocha-framework": "^9.0.6",
"cross-env": "^7.0.3",
"electron": "^32.0.1",
"global-jsdom": "^24.0.0",
"jsdom": "^24.1.1",
"rollup": "^4.21.0",
"ts-loader": "^9.4.4",
"tsx": "^4.17.0",
"typescript": "^5.5.4",
"webdriverio": "^9.0.7"
},
"peerDependencies": {
"typescript": "5.2.2"
"@wdio/cli": "^9.0.9",
"@wdio/globals": "^9.0.9",
"@wdio/local-runner": "^9.0.9",
"@wdio/mocha-framework": "^9.0.8",
"electron": "^32.0.2",
"rollup": "^4.21.2",
"tsx": "^4.19.0",
"typescript": "^5.6.2",
"webdriverio": "^9.0.9"
}
}
Loading