Skip to content

Commit

Permalink
feat: sort config items in ascending priority
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jul 28, 2020
1 parent 88d690f commit 7c1c2ac
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 124 deletions.
@@ -1,5 +1,5 @@
{
"args": ["./src"],
"args": ["./src", "--out-file", "./test.js"],
"os": ["win32"],
"env": {
"BABEL_SHOW_CONFIG_FOR": "./src/foo.js"
Expand Down
@@ -0,0 +1 @@
"use strict";
@@ -1,3 +1,18 @@
Babel configs on "<CWD>/src/foo.js" (ascending priority):
config <CWD>/babel.config.json
{
"sourceType": "script"
}

config <CWD>/babel.config.json .overrides[0]
{
"test": "src/foo.js",
"sourceType": "module"
}

config <CWD>/.babelrc
{}

programmatic options from @babel/cli
{
"sourceFileName": "src/foo.js",
Expand All @@ -14,18 +29,4 @@ programmatic options from @babel/cli
},
"filename": "src//foo.js"
}

config <CWD>/.babelrc
{}

config <CWD>/babel.config.json
{
"sourceType": "script"
}

config <CWD>/babel.config.json .overrides[0]
{
"test": "src/foo.js",
"sourceType": "module"
}
"use strict";
Successfully compiled 1 file with Babel (123ms).
@@ -1,5 +1,5 @@
{
"args": ["./src"],
"args": ["./src", "--out-file", "./test.js"],
"os": ["darwin", "linux"],
"env": {
"BABEL_SHOW_CONFIG_FOR": "./src/foo.js"
Expand Down
@@ -0,0 +1 @@
"use strict";
@@ -1,3 +1,18 @@
Babel configs on "<CWD>/src/foo.js" (ascending priority):
config <CWD>/babel.config.json
{
"sourceType": "script"
}

config <CWD>/babel.config.json .overrides[0]
{
"test": "src/foo.js",
"sourceType": "module"
}

config <CWD>/.babelrc
{}

programmatic options from @babel/cli
{
"sourceFileName": "src/foo.js",
Expand All @@ -14,18 +29,3 @@ programmatic options from @babel/cli
},
"filename": "src/foo.js"
}

config <CWD>/.babelrc
{}

config <CWD>/babel.config.json
{
"sourceType": "script"
}

config <CWD>/babel.config.json .overrides[0]
{
"test": "src/foo.js",
"sourceType": "module"
}
"use strict";
@@ -1,3 +1,18 @@
Babel configs on "<CWD>/src/foo.js" (ascending priority):
config <CWD>/babel.config.json
{
"sourceType": "script"
}

config <CWD>/babel.config.json .overrides[0]
{
"test": "src/foo.js",
"sourceType": "module"
}

config <CWD>/.babelrc
{}

programmatic options from @babel/cli
{
"sourceFileName": "../src/foo.js",
Expand All @@ -14,18 +29,4 @@ programmatic options from @babel/cli
},
"filename": "src//foo.js"
}

config <CWD>/.babelrc
{}

config <CWD>/babel.config.json
{
"sourceType": "script"
}

config <CWD>/babel.config.json .overrides[0]
{
"test": "src/foo.js",
"sourceType": "module"
}
Successfully compiled 1 file with Babel (123ms).
@@ -1,67 +1,51 @@
programmatic options from @babel/cli
Babel configs on "<CWD>/src/index.js" (ascending priority):
config <CWD>/my-extended.js
{
"sourceFileName": "./src/index.js",
"sourceMaps": false,
"presets": [
"<ROOTDIR>/packages/babel-preset-react"
],
"plugins": [
"<ROOTDIR>/packages/babel-plugin-transform-arrow-functions",
"<ROOTDIR>/packages/babel-plugin-transform-strict-mode",
"<ROOTDIR>/packages/babel-plugin-transform-modules-commonjs"
],
"configFile": "./my-config.js",
"caller": {
"name": "@babel/cli"
},
"filename": "./src/index.js"
}

config <CWD>/.babelrc
{}

config <CWD>/my-config.js
{
"sourceType": "script",
"plugins": [
"[Function: (api) => ({/n name: /"@foo//" + __dirname,/n visitor ... ]"
],
"extends": "./my-extended.js"
"@foo/babel-preset-1"
]
}

config <CWD>/my-config.js .env["test"]
config <CWD>/my-extended.js .env["test"]
{
"plugins": [
"presets": [
[
"@foo/babel-plugin-3",
"@foo/babel-preset-3",
{
"noDocumentAll": true
},
"@foo/babel-plugin-three"
"@foo/babel-preset-three"
]
]
}

config <CWD>/my-config.js .overrides[0]
config <CWD>/my-extended.js .overrides[0]
{
"test": "src/index.js",
"plugins": [
"presets": [
[
"@foo/babel-plugin-2",
"@foo/babel-preset-2",
{
"noDocumentAll": true
}
]
]
}

config <CWD>/my-config.js .overrides[0].env["test"]
config <CWD>/my-extended.js .overrides[0].env["test"]
{
"plugins": [
"@foo/babel-plugin-1",
"presets": [
"@foo/babel-preset-1",
[
{
"name": "@foo/inline-babel-plugin-1",
"visitor": {}
"name": "@foo/inline-babel-preset-1",
"plugins": [
{
"name": "@foo/inline-babel-plugin-1",
"visitor": {}
}
]
},
{
"noDocumentAll": true
Expand All @@ -70,57 +54,74 @@ config <CWD>/my-config.js .overrides[0].env["test"]
]
}

config <CWD>/my-extended.js
config <CWD>/my-config.js
{
"sourceMaps": false,
"presets": [
"@foo/babel-preset-1"
]
"sourceType": "script",
"plugins": [
"[Function: (api) => ({/n name: /"@foo//" + __dirname,/n visitor ... ]"
],
"extends": "./my-extended.js"
}

config <CWD>/my-extended.js .env["test"]
config <CWD>/my-config.js .env["test"]
{
"presets": [
"plugins": [
[
"@foo/babel-preset-3",
"@foo/babel-plugin-3",
{
"noDocumentAll": true
},
"@foo/babel-preset-three"
"@foo/babel-plugin-three"
]
]
}

config <CWD>/my-extended.js .overrides[0]
config <CWD>/my-config.js .overrides[0]
{
"test": "src/index.js",
"presets": [
"plugins": [
[
"@foo/babel-preset-2",
"@foo/babel-plugin-2",
{
"noDocumentAll": true
}
]
]
}

config <CWD>/my-extended.js .overrides[0].env["test"]
config <CWD>/my-config.js .overrides[0].env["test"]
{
"presets": [
"@foo/babel-preset-1",
"plugins": [
"@foo/babel-plugin-1",
[
{
"name": "@foo/inline-babel-preset-1",
"plugins": [
{
"name": "@foo/inline-babel-plugin-1",
"visitor": {}
}
]
"name": "@foo/inline-babel-plugin-1",
"visitor": {}
},
{
"noDocumentAll": true
}
]
]
}

config <CWD>/.babelrc
{}

programmatic options from @babel/cli
{
"sourceFileName": "./src/index.js",
"presets": [
"<ROOTDIR>/packages/babel-preset-react"
],
"plugins": [
"<ROOTDIR>/packages/babel-plugin-transform-arrow-functions",
"<ROOTDIR>/packages/babel-plugin-transform-strict-mode",
"<ROOTDIR>/packages/babel-plugin-transform-modules-commonjs"
],
"configFile": "./my-config.js",
"caller": {
"name": "@babel/cli"
},
"filename": "./src/index.js"
}

0 comments on commit 7c1c2ac

Please sign in to comment.