Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove top-level `"use strict";`. It can cause problems with bundlers that concatenate scripts, and so is not a recommended practice.
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.ExpressionStatement).filter(path => (
path.parentPath.node.type === "Program" &&
path.value.expression.type === 'Literal' &&
path.value.expression.value === 'use strict'
))
.forEach(path => j(path).remove())
.toSource();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.