reboost
Version:
A super fast dev server for rapid web development
26 lines (25 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommonJSMode2Plugin = exports.runTransformation = void 0;
const tslib_1 = require("tslib");
const anymatch_1 = (0, tslib_1.__importDefault)(require("anymatch"));
const commonjs_to_es6_1 = require("./commonjs-to-es6");
Object.defineProperty(exports, "runTransformation", { enumerable: true, get: function () { return commonjs_to_es6_1.transformCommonJSToES6; } });
const utils_1 = require("../../utils");
const CommonJSMode2Plugin = (instance) => {
const test = (file) => (!(0, anymatch_1.default)(instance.config.commonJSInterop.exclude, file) &&
(0, anymatch_1.default)(instance.config.commonJSInterop.include, file));
return {
name: 'core-commonjs-mode-2-plugin',
getCacheKey: ({ serializeObject }) => serializeObject({
include: instance.config.commonJSInterop.include,
exclude: instance.config.commonJSInterop.exclude
}),
transformAST(programPath, _, filePath) {
if (test(filePath)) {
(0, commonjs_to_es6_1.transformCommonJSToES6)(programPath, (0, utils_1.uniqueID)(6));
}
}
};
};
exports.CommonJSMode2Plugin = CommonJSMode2Plugin;