Skip to content

Conversation

@rubencarvalho
Copy link
Contributor

@rubencarvalho rubencarvalho commented Oct 17, 2025

Description

This PR includes several infrastructure improvements and fixes to improve the DX across first-gen and second-gen. I kept the commit history fairly specific so you can follow each improvement "step by step".

  • Restored web-dev-server for first-gen documentation
  • Fixed import/export inconsistencies and added process.env.NODE_ENV replacement plugin that was preventing the dev server from starting
  • Enabled second-gen test coverage collection in first-gen tests
  • Created a patch for @web/test-runner-coverage-v8 that correctly resolves __wds-outside-root__ file paths, to allow coverage to be collected for second-gen core base classes imported via alias in first-gen tests
  • Expanded second-gen core exports (updated package.json exports to support both .js extensions and extensionless imports for better compatibility)
  • Re-exported SizedMixin from second-gen
  • Added Adobe Clean font to second-gen Storybook

Motivation and context

  • For the Web Dev Server issue, the first-gen documentation site's web-dev-server was broken due to missing process.env.NODE_ENV replacement causing runtime errors (e.g. window.__swc would not be defined) and import/export inconsistencies when resolving second-gen dependencies.
  • When first-gen tests import second-gen components (via @swc/core/* alias), the files are served with __wds-outside-root__ URL prefixes. The coverage tool attempted to resolve these paths by naively joining them with the root directory, creating invalid paths like:
first-gen/__wds-outside-root__/1/second-gen/... ❌

The patch detects this special URL pattern and correctly resolves to:

/Users/.../spectrum-web-components/second-gen/... ✅

This enables proper coverage collection and reporting for second-gen source files (via source maps) when tested through first-gen test suites.

Related issue(s)

  • This is done under the barebones efforts

Screenshots (if appropriate)


Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Verify web-dev-server starts correctly for first-gen documentation
  1. Run yarn docs:start inside first-gen/
  2. Navigate to the documentation site
  3. Expect the server to start without errors and the site to load properly
  • Verify coverage collection includes second-gen files
  1. Run tests with coverage enabled (yarn workspace @adobe/spectrum-web-components test:focus unit --config web-test-runner.config.ci-chromium.js --coverage)
  2. Check the coverage report at first-gen/coverage/lcov-report/index.html
  3. Expect to see second-gen/packages/core/components/* entries in the coverage report
  4. Expect no errors about missing __wds-outside-root__ paths in the test output
  • Verify second-gen Storybook displays Adobe Clean font
  1. Start second-gen Storybook (yarn storybook inside second-gen/packages/swc/)
  2. Inspect typography in component stories (e.g. Badge)
  3. Expect Adobe Clean font to be loaded and applied (you can compare with main Storybook state)

@changeset-bot
Copy link

changeset-bot bot commented Oct 17, 2025

⚠️ No Changeset found

Latest commit: 460123d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 17, 2025

📚 Branch Preview

🔍 Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-5811

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@github-actions
Copy link
Contributor

Tachometer results

Currently, no packages are changed by this PR...

@rubencarvalho rubencarvalho marked this pull request as ready for review October 17, 2025 14:34
@rubencarvalho rubencarvalho requested a review from a team as a code owner October 17, 2025 14:34
@rubencarvalho rubencarvalho changed the title Ruben/barebones cleanup and improvements chore(barebones): improve infrastructure and testing setup Oct 17, 2025
@rubencarvalho rubencarvalho added 2nd gen These issues or PRs map to our 2nd generation work to modernizing infrastructure. Tooling labels Oct 20, 2025
@caseyisonit caseyisonit added the Status: Ready for review PR ready for review or re-review. label Oct 20, 2025
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were using vite at the moment because the web-dev-server was not working without the current updated exports from the core nor the process.env resolution. Now it is no longer needed so we are restoring the previous behaviour (that you still find on main.

const json = fromRollup(rollupJson);

// Custom plugin to replace process.env.NODE_ENV in all files
const replaceProcessEnv = () => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The web-dev-server does not automatically pass the process.env resolution to the imported modules, so we need this middleware to manually handle it.

}
return SizedElement;
}
export * from '@swc/core/shared/base/sizedMixin.js';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had forgotten to re-export this from 2nd-gen, now that it is there :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Becausesecond-gen/ is being served outside of the root of the first-gen/ project, web-test-runner would not be able to correctly resolve the path and collect the coverage. Patching this fixes it!

Copy link
Contributor

@nikkimk nikkimk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after yarn workspace @adobe/spectrum-web-components test:focus unit --config web-test-runner.config.ci-chromium.js --coverage:

tools/truncated/test/truncated.test.js:

 🚧 Browser logs:
      TypeError: Failed to fetch dynamically imported module: https://localhost:8000/tools/truncated/test/truncated.test.js?wtr-session-id=b5Cx2rMCcbUL8Vm3FUCcw

 ❌ Could not import your test module. Check the browser logs or open the browser in debug mode for more information.

@caseyisonit caseyisonit added the High Priority PR Review PR is a high priority and should be reviewed ASAP label Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2nd gen These issues or PRs map to our 2nd generation work to modernizing infrastructure. High Priority PR Review PR is a high priority and should be reviewed ASAP Status: Ready for review PR ready for review or re-review. Tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants