Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document (or change) nested arrays for package.json transform field? #65

Open
mikemaccana opened this issue Nov 3, 2015 · 3 comments
Open

Comments

@mikemaccana
Copy link

From babel/babelify#142, it seems the syntax where individual transforms are specified as arrays is correct.

"browserify": {
    "transform": [
        "brfs",
        [
            "babelify", 
            { 
                "presets": ["es2015"] 
            }
        ]
    ]
}

The syntax for this part:

 [
    "babelify", 
    { 
        "presets": ["es2015"] 
    }
 ]

is odd: the array doesn't seem to be used as an ordered list of items. "babelify" is item 0, {"presets": ["es2015"]} is item 1. What would item 2 be?

If there wouldn't ever be an item 2, and this is simply a map between babelify and babelify's options, wouldn't an object be more logical?

"browserify": {
    "transform": [
        "brfs",
        {
            "babelify": { 
                "presets": ["es2015"] 
            }
        }
    ]
} 
@mikemaccana
Copy link
Author

The docs mention:

"If you want to pass options to the transforms, you can use a 2-element array inside of the primary array. Here fff gets an options object with {"x":3} and ggg gets {"y":4}:"

 {
   "foo": {
     "bar": [["fff",{"x":3}],["ggg",{"y":4}]]
   }
 }

Using an object would be a logical way to map "fff" and "ggg" to their respective options.

@ghost
Copy link

ghost commented Nov 6, 2015

Using a key this way makes some semantics ambiguous:

{
  "babelify": { 
    "presets": ["es2015"] 
  }
}

What if there is another key? This would be better:

{
  "name": "babelify",
  "options": {
    "presets": "es2015"
  }
}

but that is much more verbose than the array form.

@mikemaccana
Copy link
Author

Thanks for the quick reply Substack! LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant