0.0.4 • Published 4 years ago

@travellocal/babel-plugin-declare-const-enum v0.0.4

Weekly downloads
91
License
MIT
Repository
github
Last release
4 years ago

@travellocal/babel-plugin-declare-const-enum

npm

A plugin for Babel to replace uses of declare const enum types from ambient typing files (i.e. .d.ts).

During the Babel run, this plugin

  • finds the relevant tsconfig.json file for each /.ts(x)?/ file encountered
  • uses the TypeScript compiler to find ambient const enums
  • replaces any usages of the const enum with the value defined (e.g. if MyEnum.Foo == 1, this plugin will replace MyEnum.Foo with 1).

Usage

First yarn add -D or npm install --save-dev @travellocal/babel-plugin-declare-const-enum.

With Storybook (v6+)

In .storybook/main.js,

module.exports = {
  // ...
  babel: async (options) => {
    // Make sure this plugin is loaded first
    options.plugins.unshift(require.resolve('@travellocal/babel-plugin-declare-const-enum'))
    return options;
  },
  // ...
};

With NextJS

Just add it to your .babelrc

{
  "presets": [
    "next/babel"
  ],
  "plugins": [
    "@travellocal/babel-plugin-declare-const-enum"
  ]
}
0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago