-
Notifications
You must be signed in to change notification settings - Fork 64
Generating source map from command line? #84
Comments
Could you resolve it? It seems it's not yet an option. Here's a quick script I wrote to compile it, replace your options as needed: const closureCompiler = require('google-closure-compiler-js');
const fs = require('fs');
if (process.argv.length !== 4) {
console.log(process.argv);
console.log("Usage: node " + __filename + " inputFile outputFile");
process.exit(1);
}
const inputPath = process.argv[2];
const outputPath = process.argv[3];
if (!fs.existsSync(inputPath)) {
console.log('Input file does not exists: ' + inputPath);
process.exit(1);
}
const src = fs.readFileSync(inputPath).toString();
const getErrorMessage = (e) => {
return [
'Compile error in file: ' + path,
'- Type: ' + e.type,
'- Line: ' + e.lineNo,
'- Char : ' + e.charNo,
'- Description: ' + e.description
].join('\n');
};
/**
* Use same options as defined in https://github.com/highcharts/highcharts/blob/master/gulpfile.js (search for "closureCompiler.compile")
*/
const out = closureCompiler.compile({
compilationLevel: 'SIMPLE_OPTIMIZATIONS',
jsCode: [{
src: src
}],
languageIn: 'ES5',
languageOut: 'ES5',
createSourceMap: true
});
const errors = out.errors;
if (errors.length) {
const msg = errors.map((e) => {
return getErrorMessage(e);
}).join('\n');
console.log("Ooops, there was a compiler error\n");
console.log(msg);
process.exit(1);
}
fs.writeFileSync(outputPath, out.compiledCode);
fs.writeFileSync(outputPath + '.map', out.sourceMap);
process.exit(0); |
I'm afraid not. |
I just stumbled upon the same problem. I added a PR #87 to fix. You can extract the source map with The |
The JS version does currently support filesystem operations. I'm looking at adding that, but its not currently an option. The source map is created, but the consumer is responsible for writing out the file. |
Can a source map be generated when calling google-closure-compiler-js from the command line?
I can pass
--createSourceMap true
but can't find any map files generated.So far I've been using the pipe output so I guess the map can't be sent there.
Using
--jsOutputFile test.js
gives the error:Unhandled flag: jsOutputFile
.The text was updated successfully, but these errors were encountered: