babel-plugin-jsonx
Version:
49 lines (47 loc) • 1.34 kB
JavaScript
// (function (global, name, factory) {
// "use strict";
// if (typeof exports === 'object' && typeof module !== 'undefined') {
// module.exports = factory;
// } else {
// global[name] = factory;
// }
// }(this, "JSONX", function (codes) {
// var data = _f(codes);
// var replacedCodes = data.replacedCodes
// var matchedObj = data.matchedObj
// var kys = Object.keys(matchedObj)
// replacedCodes = replacedCodes.replace(/\s*\/\/.*$/mg, '');
// for (var i = 0; i < kys.length; i++) {
// replacedCodes = replacedCodes.replace(kys[i], matchedObj[kys[i]]);
// }
// return replacedCodes;
// function _f(codes) {
// var matchedObj = {};
// var replacedCodes = '';
// var regQuotation = /".*\/\/.*"/mg;
// var uniqueStr = 'QUOTATIONMARKS' + Math.floor(Math.random() * 10000);
// var index = 0;
// replacedCodes = codes.replace(regQuotation, function (match) {
// var s = uniqueStr + (index++);
// matchedObj[s] = match;
// return s;
// });
// return {
// replacedCodes,
// matchedObj
// };
// }
// }));
module.exports = function ({
types: babelTypes
}) {
return {
name: "babel-plugin-jsonx",
visitor: {
Identifier(path, state) {
console.log('Identifier',
babelTypes, path, state)
}
}
};
};