Skip to content

Conversation

@sheremet-va
Copy link
Member

Description

This PR adds a new option to use Node Loaders without relying on Vite transforms at all.

Related #7200
Related #2841

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Jan 13, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit b2d1cf4
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/67a3904b0351d800089edea9
😎 Deploy Preview https://deploy-preview-7234--vitest-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 site configuration.

@sheremet-va sheremet-va added this to the 3.1.0 milestone Jan 14, 2025
@ffMathy
Copy link

ffMathy commented Jan 16, 2025

This is great. Should it be default for Node versions 23.6 and later?

export default defineConfig({
test: {
experimental: {
nativeImports: true,
Copy link
Member Author

@sheremet-va sheremet-va Mar 17, 2025

Choose a reason for hiding this comment

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

const config = {
  test: {
    loader: '../my-loader.js'
  }
}

// works in test thread
const loader = importLoader('custom-file')
loader.import('custom-env')

// works on the server
const server = {
  loadCoverageProvider() {
    const loader = importLoader()
    loader.import('file')
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants