1.0.1 • Published 3 years ago

babel-plugin-disallow-top-level-identifier v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

babel-plugin-disallow-top-level-identifier

A very simple Babel plugin to rename some problematic identifiers from the top level of a module.

Example Babel config:

{
  "plugins": [
    ["disallow-identifier", {
      "disallow": ["module", "exports"]
    }]
  ]
}

Input:

// Gets renamed because the variable is in the top level of the file
let module = 'f';
module += 'oo'

function bar() {
  // Doesn't get renamed because the variable is in a function
  const module = 'foo';
  return module + 'ooo';
}

export { module }

Output:

// Gets renamed because the variable is in the top level of the file
let _module = 'f';
_module += 'oo';

function bar() {
  // Doesn't get renamed because the variable is in a function
  const module = 'foo';
  return module + 'ooo';
}

export { _module as module };