Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
// Rename the bindings auto-injected into the scope so there is no
// risk of conflict between the bindings.
path.scope.rename("exports");
path.scope.rename("module");
path.scope.rename("require");
path.scope.rename("__filename");
path.scope.rename("__dirname");
// Rewrite references to 'module' and 'exports' to throw exceptions.
// These objects are specific to CommonJS and are not available in
// real ES6 implementations.
if (!allowCommonJSExports) {
simplifyAccess(path, new Set(["module", "exports"]));
path.traverse(moduleExportsVisitor, {
scope: path.scope,
exit(path, state) {
if (!isModule(path)) return;
// Rename the bindings auto-injected into the scope so there is no
// risk of conflict between the bindings.
path.scope.rename("exports");
path.scope.rename("module");
path.scope.rename("require");
path.scope.rename("__filename");
path.scope.rename("__dirname");
// Rewrite references to 'module' and 'exports' to throw exceptions.
// These objects are specific to CommonJS and are not available in
// real ES6 implementations.
if (!allowCommonJSExports) {
simplifyAccess(path, new Set(["module", "exports"]));
path.traverse(moduleExportsVisitor, {
scope: path.scope,
exit(path) {
if (!isModule(path)) return;
const browserGlobals = globals || {};
let moduleName = this.getModuleName();
if (moduleName) moduleName = t.stringLiteral(moduleName);
const { meta, headers } = rewriteModuleStatementsAndPrepareHeader(
path,
{
loose,
strict,
strictMode,
allowTopLevelThis,
noInterop,
},
);
exit(path) {
if (!isModule(path)) return;
const browserGlobals = globals || {};
let moduleName = this.getModuleName();
if (moduleName) moduleName = t.stringLiteral(moduleName);
const {
meta,
headers,
} = rewriteModuleStatementsAndPrepareHeader(path, {
loose,
strict,
strictMode,
allowTopLevelThis,
noInterop,
});
exit(path) {
if (!isModule(path)) return;
let moduleName = this.getModuleName();
if (moduleName) moduleName = t.stringLiteral(moduleName);
const {
meta,
headers,
} = rewriteModuleStatementsAndPrepareHeader(path, {
loose,
strict,
strictMode,
allowTopLevelThis,
noInterop,
});
const amdArgs = [];
exit(path, { requireId }) {
if (!isModule(path)) {
if (requireId) {
injectWrapper(
path,
buildAnonymousWrapper({ REQUIRE: requireId }),
);
}
return;
}
const amdArgs = [];
const importNames = [];
if (requireId) {
amdArgs.push(t.stringLiteral("require"));
importNames.push(requireId);
}