Skip to content

Commit

Permalink
fix(compile): provide filename to babel transform to allow using conf…
Browse files Browse the repository at this point in the history
…ig files (#1218)

Co-authored-by: Gary Mathews <[email protected]>

Fixes ALOY-1749
  • Loading branch information
ewanharris authored Sep 17, 2021
1 parent 32186ec commit ba0068e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Alloy/commands/compile/sourceMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ exports.generateCodeAndSourceMap = function(generator, compileConfig) {
file: `${compileConfig.dir.project}/${relativeOutfile}`,
sourceRoot: compileConfig.dir.project
});
// try to lookup the filename, falling back to the output file if we can't determine it
let filename;
if (data.__MAPMARKER_CONTROLLER_CODE__ && data.__MAPMARKER_CONTROLLER_CODE__.filename) {
filename = data.__MAPMARKER_CONTROLLER_CODE__.filename;
} else if (data.__MAPMARKER_ALLOY_JS__ && data.__MAPMARKER_ALLOY_JS__.filename) {
filename = data.__MAPMARKER_ALLOY_JS__.filename;
} else if (data.__MAPMARKER_NONCONTROLLER__ && data.__MAPMARKER_NONCONTROLLER__.filename) {
filename = data.__MAPMARKER_NONCONTROLLER__.filename;
} else {
filename = target.filename;
}
// the line counter and code string for the generated file
var genMap = {
count: 1,
Expand Down Expand Up @@ -124,7 +135,8 @@ exports.generateCodeAndSourceMap = function(generator, compileConfig) {
plugins: [
[require('./ast/builtins-plugin'), compileConfig],
[require('./ast/optimizer-plugin'), compileConfig.alloyConfig]
]
],
filename
});
if (compileConfig.sourcemap) {
// Tell babel to retain the lines so they stay correct (columns go wacky, but OH WELL)
Expand Down

0 comments on commit ba0068e

Please sign in to comment.