1.5.2 • Published 12 days ago

swc-plugin-import-meta-env v1.5.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
12 days ago

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.

1.5.2

12 days ago

1.5.1

13 days ago

1.5.0

16 days ago

1.4.17

16 days ago

1.4.16

21 days ago

1.4.12

1 month ago

1.4.8

2 months ago

1.4.7

2 months ago

1.4.6

2 months ago

1.4.5

2 months ago

1.4.4

2 months ago

1.4.2

2 months ago

1.4.1

2 months ago

1.4.0

3 months ago

0.5.0

4 months ago

0.4.1

4 months ago

0.4.0

4 months ago

0.3.0

5 months ago

0.2.1

5 months ago

0.2.0

5 months ago

0.1.7

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago