Skip to content

[javascript] Create @seleniumhq/atoms npm package from TypeScript atoms#17459

Open
AutomatedTester wants to merge 2 commits into
trunkfrom
priceless-cannon-76a1b6
Open

[javascript] Create @seleniumhq/atoms npm package from TypeScript atoms#17459
AutomatedTester wants to merge 2 commits into
trunkfrom
priceless-cannon-76a1b6

Conversation

@AutomatedTester
Copy link
Copy Markdown
Member

Refactors the three TypeScript atoms (get-attribute, find-elements, is-displayed) from IIFE closures to proper ES modules with export default, then produces two compilation targets from the same sources:

  • IIFE path (language bindings): ts_project --module commonjs → cjs-to-iife.js → browser-injectable (function(){…return fn;})() so py/rb/java/dotnet consumers are unchanged.

  • npm path: ts_project --module esnext + declaration → dist/ published as @seleniumhq/atoms with full TypeScript type declarations.

Key changes:

  • Remove outer IIFE from all three atom .ts files; add export default.
  • Add cjs-to-iife.js replacing strip-trailing-semicolon.js in the IIFE pipeline. Strips CJS boilerplate and wraps the body in an IIFE that returns the exported default function.
  • Update wrap-as-global scripts to parse CJS-compiled input instead of asserting (function () at the start.
  • Switch BUILD.bazel from js_run_binary+tsc(--module none --outFile) to ts_project for each atom, plus a new npm_package target.
  • Add tsconfig.json (esnext, declaration) and tsconfig-cjs.json for the two compilation paths.
  • Add index.ts as the package entry point.
  • Promote javascript/atoms/package.json to @seleniumhq/atoms v4.45.x.
  • Add get_attribute_typescript and find-elements-typescript CJS module targets to selenium-webdriver/lib/atoms/BUILD.bazel.

All 25 Python unit tests pass; //javascript/atoms:closure-test passes.

🔗 Related Issues

💥 What does this PR do?

🔧 Implementation Notes

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s): Claude
    • What was generated: Templates
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

🔄 Types of changes

  • Cleanup (formatting, renaming)
  • Bug fix (backwards compatible)
  • New feature (non-breaking change which adds functionality and tests!)
  • Breaking change (fix or feature that would cause existing functionality to change)

Refactors the three TypeScript atoms (get-attribute, find-elements,
is-displayed) from IIFE closures to proper ES modules with export
default, then produces two compilation targets from the same sources:

- IIFE path (language bindings): ts_project --module commonjs →
  cjs-to-iife.js → browser-injectable (function(){…return fn;})()
  so py/rb/java/dotnet consumers are unchanged.

- npm path: ts_project --module esnext + declaration → dist/ published
  as @seleniumhq/atoms with full TypeScript type declarations.

Key changes:
* Remove outer IIFE from all three atom .ts files; add export default.
* Add cjs-to-iife.js replacing strip-trailing-semicolon.js in the
  IIFE pipeline. Strips CJS boilerplate and wraps the body in an IIFE
  that returns the exported default function.
* Update wrap-as-global scripts to parse CJS-compiled input instead of
  asserting (function () at the start.
* Switch BUILD.bazel from js_run_binary+tsc(--module none --outFile)
  to ts_project for each atom, plus a new npm_package target.
* Add tsconfig.json (esnext, declaration) and tsconfig-cjs.json for
  the two compilation paths.
* Add index.ts as the package entry point.
* Promote javascript/atoms/package.json to @seleniumhq/atoms v4.45.x.
* Add get_attribute_typescript and find-elements-typescript CJS module
  targets to selenium-webdriver/lib/atoms/BUILD.bazel.

All 25 Python unit tests pass; //javascript/atoms:closure-test passes.
@selenium-ci selenium-ci added B-atoms JavaScript chunks generated by Google closure C-nodejs JavaScript Bindings B-build Includes scripting, bazel and CI integrations labels May 14, 2026
…roject targets

When multiple ts_project targets share a single tsconfig with no files/include
restriction, tsc compiles all .ts files for each target. On Windows, Bazel marks
outputs read-only after the first action completes; parallel actions then fail
with TS5033 EPERM trying to overwrite the same files.

Give each per-atom ts_project its own tsconfig that lists only the one .ts file
it is responsible for, eliminating the cross-target output collision.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-atoms JavaScript chunks generated by Google closure B-build Includes scripting, bazel and CI integrations C-nodejs JavaScript Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants