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
Misc reorganizing and prep for ignore/only refactoring #5467
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
540f9b2
Remove the nonstandard basename option.
loganfsmyth 188fe10
Move option-defaulting to option-manager.
loganfsmyth c1be6a3
Delete Logger class.
loganfsmyth 83356ab
Centralize transform API functions.
loganfsmyth 738bd54
Move OptionManager calls out of 'new File'.
loganfsmyth dcb0f91
Ignore files if they don't match only OR they do match ignore.
loganfsmyth bf4664b
Invert the resolution order of config-chain to process higher-priorit…
loganfsmyth File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,29 @@ | ||
import fs from "fs"; | ||
|
||
export { default as File } from "./transformation/file"; | ||
export { default as buildExternalHelpers } from "./tools/build-external-helpers"; | ||
export { default as template } from "babel-template"; | ||
export { default as resolvePlugin } from "./helpers/resolve-plugin"; | ||
export { default as resolvePreset } from "./helpers/resolve-preset"; | ||
export File from "./transformation/file"; | ||
export buildExternalHelpers from "./tools/build-external-helpers"; | ||
export resolvePlugin from "./helpers/resolve-plugin"; | ||
export resolvePreset from "./helpers/resolve-preset"; | ||
|
||
export { version } from "../package"; | ||
export { getEnv } from "./helpers/environment"; | ||
|
||
import * as util from "./util"; | ||
export { util }; | ||
|
||
import * as messages from "babel-messages"; | ||
export { messages }; | ||
|
||
import * as t from "babel-types"; | ||
export { t as types }; | ||
export * as util from "./util"; | ||
|
||
import traverse from "babel-traverse"; | ||
export { traverse }; | ||
export * as messages from "babel-messages"; | ||
export * as types from "babel-types"; | ||
export traverse from "babel-traverse"; | ||
export template from "babel-template"; | ||
|
||
import OptionManager from "./transformation/file/options/option-manager"; | ||
export { OptionManager }; | ||
export OptionManager from "./transformation/file/options/option-manager"; | ||
|
||
export function Plugin(alias) { | ||
throw new Error(`The (${alias}) Babel 5 plugin is being run with Babel 6.`); | ||
} | ||
|
||
import { transform, analyse, transformFromAst } from "./transformation/pipeline"; | ||
export { transform, analyse, transformFromAst }; | ||
|
||
export function transformFile(filename: string, opts?: Object, callback: Function) { | ||
if (typeof opts === "function") { | ||
callback = opts; | ||
opts = {}; | ||
} | ||
|
||
opts.filename = filename; | ||
export { | ||
transform, | ||
analyse, | ||
transformFromAst, | ||
transformFile, | ||
transformFileSync, | ||
} from "./transformation/pipeline"; | ||
|
||
fs.readFile(filename, function (err, code) { | ||
let result; | ||
|
||
if (!err) { | ||
try { | ||
result = transform(code, opts); | ||
} catch (_err) { | ||
err = _err; | ||
} | ||
} | ||
|
||
if (err) { | ||
callback(err); | ||
} else { | ||
callback(null, result); | ||
} | ||
}); | ||
} | ||
|
||
export function transformFileSync(filename: string, opts?: Object = {}): string { | ||
opts.filename = filename; | ||
return transform(fs.readFileSync(filename, "utf8"), opts); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By swapping the order of these, we'll be able to bail out based on
ignore
andonly
match failure, before having to search for the.babelrc
which will be a big performance win.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's really good 🚀