babel-plugin-preserve-comment-header

Explicitly preserve the location of any header comments that match a given pattern.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-preserve-comment-header
1.0.16 years ago6 years agoMinified + gzip package size for babel-plugin-preserve-comment-header in KB

Readme

babel-plugin-preserve-comment-header
Explicitly ensure that the first comment at the top of the processed file, if it matches the given pattern, stays at the top of the file.
Often Babel will insert use strict or any number of other things at the top of a file. While often the top comment will just be documentation attached to the first function, and thus should be pushed down, sometimes these comments are things like license headers, which should be left at the top.

Usage

{
  "plugins": [
    "babel-plugin-preserve-comment-header"
  ]
}

which will by default preserve any comments containing the test @license.

Custom pattern

{
  "plugins": [
    ["babel-plugin-preserve-comment-header", { pattern: "customString" }]
  ]
}

or if you are in a non-JSON config, a RegExp is also permitted:
{
  "plugins": [
    ["babel-plugin-preserve-comment-header", { pattern: /customString/ }]
  ]
}