Skip to content

Commit

Permalink
fix: importing some Marko files properly includes meta
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jan 25, 2021
1 parent 8113e25 commit d67bac5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 0 additions & 4 deletions packages/babel-utils/src/tags.js
Expand Up @@ -206,10 +206,6 @@ export function resolveTagImport(path, request) {
}

if (request.endsWith(".marko")) {
if (!file.metadata.marko.tags.includes(request)) {
file.metadata.marko.tags.push(request);
}

return resolveRelativePath(file, request);
}
}
12 changes: 10 additions & 2 deletions packages/translator-default/src/index.js
Expand Up @@ -352,8 +352,16 @@ export const translate = {
ImportDeclaration: {
exit(path) {
const source = path.get("source");
const request = source.node.value;
source.node.value = resolveTagImport(source, request) || request;
const tagEntry = resolveTagImport(source, source.node.value);

if (tagEntry) {
const meta = path.hub.file.metadata.marko;
source.node.value = tagEntry;

if (!meta.tags.includes(tagEntry)) {
meta.tags.push(tagEntry);
}
}
}
}
};
Expand Down

0 comments on commit d67bac5

Please sign in to comment.