Files
test-repo/scripts/build/rollup-plugins/evaluate.js
T
Ika 91206891cd fix(markdown): do not add whitespaces between Latin and Hangul (#5040)
Based on https://github.com/prettier/prettier/issues/5028#issuecomment-417825085, it seems Korean text uses conventional space so we're not going to add whitespaces between Latin and Hangul.
2018-09-02 16:20:22 +08:00

29 lines
567 B
JavaScript

"use strict";
module.exports = function() {
return {
name: "evaluate",
transform(_text, id) {
if (!/\.evaluate\.js$/.test(id)) {
return null;
}
const json = JSON.stringify(
require(id.replace(/^\0commonjs-proxy:/, "")),
(_, v) => {
if (typeof v === "function") {
throw new Error(`Cannot evaluate functions.`);
}
return v;
}
);
return {
code: `const json = ${json}; export default json;`,
map: { mappings: "" }
};
}
};
};