UNPKG

@ima/cli

Version:

IMA.js CLI tool to build, develop and work with IMA.js applications.

21 lines (20 loc) 973 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Converts compiled JavaScript/TypeScript source into a string export. * This loader should be placed before swc-loader in the chain. * The compilation is handled by subsequent loaders (swc-loader), * this loader just wraps the result as a string export. */ const JsStringLoader = function (source) { const options = this.getOptions(); const { includeSourceMap = false } = options; // If we have source maps and they're requested, include them if (includeSourceMap && this.sourceMap) { const sourceMapComment = `\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(this.sourceMap)).toString('base64')}`; return `export default ${JSON.stringify(source + sourceMapComment)};`; } // Return the compiled source as a string export return `export default ${JSON.stringify(source)};`; }; exports.default = JsStringLoader;