Skip to content

docs: add Commonjs interop tips#878

Merged
9aoy merged 4 commits intomainfrom
docs/interop
Jan 19, 2026
Merged

docs: add Commonjs interop tips#878
9aoy merged 4 commits intomainfrom
docs/interop

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Jan 19, 2026

Summary

Currently, Rstest does not support interoping CommonJS module default exports as named exports.

If you encounter issues during usage, you can specify the external type of a dependency as CommonJS through specifying external type.

import { defineConfig } from '@rstest/core';

export default defineConfig({
  output: {
    externals: {
      lodash: 'commonjs lodash', // externalize lodash as a CommonJS module
    },
  },
});

Related Links

#858

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 19, 2026 05:46
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 19, 2026

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit a6a2094
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/696dcccbfe074b0008a99598
😎 Deploy Preview https://deploy-preview-878--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds documentation explaining CommonJS interoperability limitations in Rstest when outputting ES modules. It addresses issue #858 by documenting that Rstest does not support interpreting CommonJS module default exports as named exports, and provides a workaround using explicit external type configuration.

Changes:

  • Added comprehensive CommonJS interop documentation section explaining behavior and limitations
  • Enhanced test fixtures to demonstrate working interop scenarios with both default and named exports
  • Simplified test-lodash fixture to clearly show the unsupported CommonJS pattern

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/docs/en/config/build/output.mdx Added English documentation section explaining CommonJS interop behavior, limitations, and workaround
website/docs/zh/config/build/output.mdx Added Chinese documentation section with same content as English version
e2e/externals/fixtures/test-pkg/interopDefault.ts Updated to import and export both default and named export 'a' from test-interop
e2e/externals/fixtures/test-lodash/index.js Simplified to minimal CommonJS pattern demonstrating unsupported use case
e2e/externals/fixtures/test-interop/index.js Added named export 'a' alongside existing default export
e2e/externals/fixtures/interopDefault.test.ts Added test assertion for the new named export 'a'

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@9aoy 9aoy merged commit 41e437f into main Jan 19, 2026
12 checks passed
@9aoy 9aoy deleted the docs/interop branch January 19, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants