Skip to content

Commit

Permalink
feat: lazy load load compiler hook paths, expose error loc object
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jul 24, 2021
1 parent 7573cd1 commit f49fc19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/compiler/src/babel-plugin/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class MarkoFile extends File {
}: ${msg}\n${frame || ""}`;

const err = new Error();
err.loc = loc;

// Prevent babel from changing our error message.
Object.defineProperty(err, "message", {
Expand Down
7 changes: 6 additions & 1 deletion packages/compiler/src/taglib/loader/loadTagFromProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ function hasAttributes(tagProps) {
function normalizeHook(dirname, value) {
if (typeof value === "string") {
value = resolveRelative(dirname, value);
return { path: value, hook: markoModules.require(value) };
return {
path: value,
get hook() {
return markoModules.require(value);
}
};
}
return { hook: value };
}
Expand Down
7 changes: 6 additions & 1 deletion packages/compiler/src/taglib/loader/loadTaglibFromProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ function resolveRelative(dirname, value) {
function normalizeHook(dirname, value) {
if (typeof value === "string") {
value = resolveRelative(dirname, value);
return { path: value, hook: markoModules.require(value) };
return {
path: value,
get hook() {
return markoModules.require(value);
}
};
}
return { hook: value };
}
Expand Down

0 comments on commit f49fc19

Please sign in to comment.