@lmiller1990/vite-plugin-proxify-esm v0.0.3
@cypress/vite-plugin-proxify-esm
A Vite plugin that intercepts and rewrites ES module imports. It wraps them in a Proxy
, allowing for instrumentation by libraries such as Sinon. Useful for test runners using Vite as a dev server.
Note: This package is a pre-release and is not yet stable. There are likely to be bugs and edge cases. Please report and bugs here
Debugging
Run Cypress with DEBUG=cypress:vite-plugin-proxify-esm
. You will get logs in the terminal, for the code transformation, and in the browser console, for intercepting and wrapping the modules in a Proxy.
Compatibility
@cypress/vite-plugin-mock-esm | cypress |
---|---|
>= v1 | >= v12 |
Known Issues
This module uses a regexp based approach to transforming the modules on the server to facilicate wrapping them in a Proxy
on the client. In future updates, a more robust AST based approach will be explored.
All known import syntax is supported with the exception of a default import combined with * as alias
in a single line.
import defaultExport3, * as name2 from "./module";
An alterntive would simply be to split the import syntax over two lines:
import defaultExport3 from "./module";
import * as name2 from "./module";
License
This project is licensed under the terms of the MIT license.