-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathloader.js
More file actions
18 lines (17 loc) · 622 Bytes
/
loader.js
File metadata and controls
18 lines (17 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const compile = require("./config/node/compile");
const config = require("./config/deriveConfig");
const path = require("path");
module.exports = function (source) {
if (typeof source !== "string" || !/\.[cme]?[tj]sx?$/.test(path.extname(this.resourcePath)))
return source;
const savedLoaderPrefix = config.loaderPrefix;
try {
config.loaderPrefix = "@effectful/debugger/loader!";
return compile(source, this.resourcePath, this._module);
} catch (e) {
console.error(`couldn't transpile ${this.resourcePath}`, e);
return source;
} finally {
config.loaderPrefix = savedLoaderPrefix;
}
};