Skip to content

Commit

Permalink
fix: upgrade to work with latest marko compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Dec 31, 2024
1 parent a211036 commit fa87e07
Show file tree
Hide file tree
Showing 17 changed files with 1,385 additions and 1,824 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-sloths-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/tags-api-preview": minor
---

Upgrades to work with latest marko compiler.
3,107 changes: 1,324 additions & 1,783 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,48 @@
"author": "Dylan Piercey <dpiercey@ebay.com>",
"bugs": "https://github.com/marko-js/tags-api-preview/issues",
"dependencies": {
"magic-string": "^0.30.7"
"magic-string": "^0.30.17"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@marko/compiler": "^5.34.7",
"@marko/fixture-snapshots": "^2.2.0",
"@changesets/cli": "^2.27.11",
"@marko/compiler": "^5.39.10",
"@marko/fixture-snapshots": "^2.2.1",
"@marko/testing-library": "^6.2.0",
"@testing-library/user-event": "^13.5.0",
"@types/babel__code-frame": "^7.0.6",
"@types/chai": "^4.3.12",
"@types/chai-as-promised": "^7.1.8",
"@types/chai-dom": "1.11.3",
"@types/jsdom": "^21.1.6",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.20",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.2",
"@types/sinon-chai": "^3.2.12",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"chai-dom": "^1.12.0",
"cross-env": "^7.0.3",
"esbuild": "^0.20.1",
"esbuild": "^0.24.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"fast-glob": "^3.3.2",
"fixpack": "^4.0.0",
"fs-monkey": "^1.0.5",
"husky": "^9.0.11",
"jsdom": "^24.0.0",
"jsdom-context-require": "^5.2.3",
"lint-staged": "^15.2.2",
"marko": "^5.32.13",
"memfs": "^4.7.7",
"fs-monkey": "^1.0.6",
"husky": "^9.1.7",
"jsdom": "^25.0.1",
"jsdom-context-require": "^5.2.4",
"lint-staged": "^15.3.0",
"marko": "^5.37.10",
"memfs": "^4.15.2",
"mocha": "^10.3.0",
"nyc": "^15.1.0",
"prettier": "^3.2.5",
"prettier": "^3.4.2",
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"unionfs": "^4.5.1"
"tsx": "^4.19.2",
"typescript": "^5.7.2",
"unionfs": "^4.5.4"
},
"files": [
"dist",
Expand All @@ -64,7 +64,7 @@
"license": "MIT",
"main": "marko.json",
"peerDependencies": {
"marko": ">= 5.22.0"
"marko": ">= 5.37.10"
},
"repository": {
"type": "git",
Expand Down
5 changes: 4 additions & 1 deletion src/components/get/transform.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import path from "path";
import { types as t } from "@marko/compiler";
import { getTagDefForTagName, importDefault } from "@marko/babel-utils";
import {
getTagDefForTagName,
importDefault,
} from "@marko/compiler/babel-utils";
import getAttr from "../../util/get-attr";

export default function transform(tag: t.NodePath<t.MarkoTag>) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/set/translate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import { types as t } from "@marko/compiler";
import { importDefault } from "@marko/babel-utils";
import { importDefault } from "@marko/compiler/babel-utils";

export default function translate(tag: t.NodePath<t.MarkoTag>) {
const file = tag.hub.file;
Expand Down
25 changes: 16 additions & 9 deletions src/components/style/transform.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import path from "path";
import MagicString, { SourceMap } from "magic-string";
import { types as t, type Config } from "@marko/compiler";
import { resolveRelativePath, importDefault } from "@marko/babel-utils";
import {
resolveRelativePath,
importDefault,
} from "@marko/compiler/babel-utils";
import getAttr from "../../util/get-attr";
import isApi from "../../util/is-api";

Expand Down Expand Up @@ -94,14 +97,18 @@ export default (tag: t.NodePath<t.MarkoTag>) => {
}
}

const resolved = resolveRelativePath(
file,
resolveVirtualDependency(filename, {
virtualPath,
map,
code,
}),
);
const virtualDep = resolveVirtualDependency(filename, {
virtualPath,
map,
code,
});

if (!virtualDep) {
tag.remove();
return;
}

const resolved = resolveRelativePath(file, virtualDep);

deps.push(resolved);
tag.replaceWith(
Expand Down
2 changes: 1 addition & 1 deletion src/transform/cached-values/transform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isNativeTag, isDynamicTag } from "@marko/babel-utils";
import { isNativeTag, isDynamicTag } from "@marko/compiler/babel-utils";
import { types as t } from "@marko/compiler";
import { importRuntimeNamed } from "../../util/import-runtime";
import isApi from "../../util/is-api";
Expand Down
2 changes: 1 addition & 1 deletion src/transform/custom-tag-var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
isDynamicTag,
isAttributeTag,
getTagDef,
} from "@marko/babel-utils";
} from "@marko/compiler/babel-utils";
import { importRuntimeDefault } from "../util/import-runtime";
import { closest } from "./wrapper-component";

Expand Down
2 changes: 1 addition & 1 deletion src/transform/feature-detection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getTagDef, isDynamicTag } from "@marko/babel-utils";
import { getTagDef, isDynamicTag } from "@marko/compiler/babel-utils";
import type { types as t } from "@marko/compiler";
import { taglibId } from "../util/taglib-id";
import { buildAggregateError } from "../util/build-aggregate-error";
Expand Down
2 changes: 1 addition & 1 deletion src/transform/hoist-tag-vars/transform.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { types as t } from "@marko/compiler";
import { isNativeTag } from "@marko/babel-utils";
import { isNativeTag } from "@marko/compiler/babel-utils";
import isCoreTag from "../../util/is-core-tag";
import { importRuntimeDefault } from "../../util/import-runtime";
import { closest } from "../wrapper-component";
Expand Down
2 changes: 1 addition & 1 deletion src/transform/native-tag-var/transform.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { types as t } from "@marko/compiler";
import { isNativeTag, isDynamicTag } from "@marko/babel-utils";
import { isNativeTag, isDynamicTag } from "@marko/compiler/babel-utils";
import isCoreTag from "../../util/is-core-tag";
import { importRuntimeDefault } from "../../util/import-runtime";
import { closest } from "../wrapper-component";
Expand Down
2 changes: 1 addition & 1 deletion src/transform/tag-body-parameters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { types as t } from "@marko/compiler";
import { getTagDef } from "@marko/babel-utils";
import { getTagDef } from "@marko/compiler/babel-utils";
import isApi from "../util/is-api";

export default {
Expand Down
7 changes: 6 additions & 1 deletion src/transform/wrapper-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
isAttributeTag,
findParentTag,
getTagDef,
} from "@marko/babel-utils";
} from "@marko/compiler/babel-utils";
import { taglibId } from "../util/taglib-id";
import isApi from "../util/is-api";

Expand Down Expand Up @@ -96,8 +96,10 @@ export default {
export function ensureLifecycle(tag: t.NodePath<t.MarkoTag>, client = true) {
const program = tag.hub.file.path;
let root = tag as t.NodePath;

while (
(root = root.parentPath!) !== program &&
root.type === "MarkoTagBody" &&
(root = root.parentPath!).node &&
isNativeTag(root as t.NodePath<t.MarkoTag>)
);
Expand Down Expand Up @@ -203,6 +205,9 @@ function isAttributeTagLike(tag: t.NodePath<t.MarkoTag>) {
}

if (isTransparentTag(tag)) {
if (tag.node.attributeTags.length) {
return true;
}
for (const child of tag.get("body").get("body")) {
if (child.isMarkoTag() && isAttributeTagLike(child)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/translate/class-api-custom-tag-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { types as t } from "@marko/compiler";
import { loadFileForTag } from "@marko/babel-utils";
import { loadFileForTag } from "@marko/compiler/babel-utils";
import isApi from "../util/is-api";
const eventNameReg = /^on[A-Z]/;

Expand Down
2 changes: 1 addition & 1 deletion src/translate/native-tag-handlers/translate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { types as t } from "@marko/compiler";
import { isNativeTag } from "@marko/babel-utils";
import { isNativeTag } from "@marko/compiler/babel-utils";
import { importRuntimeDefault } from "../../util/import-runtime";
import isApi from "../../util/is-api";
import getAttr from "../../util/get-attr";
Expand Down
2 changes: 1 addition & 1 deletion src/util/import-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { types as t } from "@marko/compiler";
import {
importDefault as _importDefault,
importNamed as _importNamed,
} from "@marko/babel-utils";
} from "@marko/compiler/babel-utils";
const prefix =
process.env.NODE_ENV === "production"
? "@marko/tags-api-preview/dist/"
Expand Down
2 changes: 1 addition & 1 deletion src/util/is-core-tag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { types as t } from "@marko/compiler";
import { getTagDef } from "@marko/babel-utils";
import { getTagDef } from "@marko/compiler/babel-utils";
import { taglibId } from "../util/taglib-id";
export default function isCoreTag<Name extends string>(
name: Name,
Expand Down

0 comments on commit fa87e07

Please sign in to comment.