Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swc-plugin-import-meta-env

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swc-plugin-import-meta-env

@swc plugin for handling the transformation of import.meta.env

  • 1.7.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

swc-plugin-import-meta-env

Simple plugin to transform import.meta.env to process.env

npm

This @swc plugin provides a simple transformation from import.meta.env to process.env.

The original purpose of this was to allow @swc usage in a large Jest test suite while also using Vite for bundling.

Install 🌱

npm i -D swc-plugin-import-meta-env

Usage 🚀

Simply add this to the plugins field of your .swcrc.

{
  "jsc": {
    "experimental": {
      "plugins": [["swc-plugin-import-meta-env", {}]]
    }
  }
}

Or programmatically as an extension to your existing .swcrc parsing:

const swcrc = JSON.parse(fs.readFileSync(".swcrc", "utf8"));
((swcrc.jsc ??= {}).experimental ??= {}).plugins = [
  ["swc-plugin-import-meta-env", {}],
]; // This may need updating to suit your requirements

How do I populate my environment? 🤔

The purpose of this plugin currently is to keep this transformation simple. There are many tools and utilities to load .env files into your environment already, such as performing this during your setupTests phase of testing.

If there is enough demand I can investigate adding this as core functionality to this plugin.

Keywords

FAQs

Package last updated on 02 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc