Move plugin processing to top of plugins (#6381)
* centralize plugin options * Centralize plugins options - move more options to the top - move validations that depend on options to the top * use isLoose option * Move more validations to the top * Move ref parameter for rewriteModuleStatementsAndPrepareHeader() to the top * fix eslint errors * remove unused parameter * set default systemGlobal value * Revert "Move ref parameter for rewriteModuleStatementsAndPrepareHeader() to the top" This reverts commit b3855302d17fa19d8acb4c8accab3680c8d2710e. * Revert "Move more validations to the top" This reverts commit e5861d8a034ff8f553391f55654f753bcf428a5d. * fix allowMutablePropsOnTags option usage * improve naming * change Contructor definition for sake of consistency * move allowMutablePropsOnTags validation to the top * add missing !
This commit is contained in:
committed by
Logan Smyth
parent
d89063bb32
commit
fcdfc61bdb
@@ -8,7 +8,17 @@ import {
|
||||
} from "babel-helper-module-transforms";
|
||||
import simplifyAccess from "babel-helper-simple-access";
|
||||
|
||||
export default function({ types: t, template }) {
|
||||
export default function({ types: t, template }, options) {
|
||||
const {
|
||||
loose,
|
||||
allowTopLevelThis,
|
||||
strict,
|
||||
strictMode,
|
||||
noInterop,
|
||||
|
||||
// Defaulting to 'true' for now. May change before 7.x major.
|
||||
allowCommonJSExports = true,
|
||||
} = options;
|
||||
const moduleAssertion = template(`
|
||||
(function(){
|
||||
throw new Error("The CommonJS 'module' variable is not available in ES6 modules.");
|
||||
@@ -85,22 +95,11 @@ export default function({ types: t, template }) {
|
||||
return {
|
||||
visitor: {
|
||||
Program: {
|
||||
exit(path, state) {
|
||||
exit(path) {
|
||||
// For now this requires unambiguous rather that just sourceType
|
||||
// because Babel currently parses all files as sourceType:module.
|
||||
if (!isModule(path, true /* requireUnambiguous */)) return;
|
||||
|
||||
const {
|
||||
loose,
|
||||
allowTopLevelThis,
|
||||
strict,
|
||||
strictMode,
|
||||
noInterop,
|
||||
|
||||
// Defaulting to 'true' for now. May change before 7.x major.
|
||||
allowCommonJSExports = true,
|
||||
} = state.opts;
|
||||
|
||||
// Rename the bindings auto-injected into the scope so there is no
|
||||
// risk of conflict between the bindings.
|
||||
path.scope.rename("exports");
|
||||
|
||||
Reference in New Issue
Block a user