mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
- Uses Ben's meteor-babel npm package that has a default config - From a checkout, uses the meteor-babel/register module and compiles at runtime - When meteor-tool is published, precompiles the files - Adds tests to make sure source maps work everywhere
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import sourceMapSupport from "source-map-support";
|
|
import fs from "fs";
|
|
|
|
// Why this file exists:
|
|
// We have two places in the tool where we need to do source maps:
|
|
// 1. Loaded isopacks, which use a special custom source map cache
|
|
// 2. Transpiled tool code from Babel
|
|
//
|
|
// In order to avoid crazy bootstrapping, it would be nice to be able to add
|
|
// functions to look for source maps, so that we can call
|
|
// sourceMapSupport.install as early as possible, and not worry about having
|
|
// the right data structures around.
|
|
//
|
|
// This module maintains a stack of source map retrieval functions, which are
|
|
// called in reverse order until one returns a truthy value.
|
|
|
|
var stack = [];
|
|
|
|
// Add a function to locate source maps; all of the functions are executed in
|
|
// reverse order
|
|
export function push(func) {
|
|
stack.push(func);
|
|
}
|
|
|
|
function tryAllSourceMapRetrievers(filename) {
|
|
for (var i = stack.length - 1; i >= 0; i--) {
|
|
var sourceMapData = stack[i](filename);
|
|
|
|
if (sourceMapData) {
|
|
return sourceMapData;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
sourceMapSupport.install({
|
|
retrieveSourceMap: tryAllSourceMapRetrievers,
|
|
// For now, don't fix the source line in uncaught exceptions, because we
|
|
// haven't fixed handleUncaughtExceptions in source-map-support to properly
|
|
// locate the source files.
|
|
handleUncaughtExceptions: false
|
|
});
|
|
|
|
// Default retrievers
|
|
|
|
// Always fall back to the default in the end
|
|
push(sourceMapSupport.retrieveSourceMap);
|
|
|
|
push(require("meteor-babel/register").retrieveSourceMap); // #RemoveInProd this line is removed in isopack.js
|