@jsenv/ast 6.9.0 → 6.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/ast",
3
- "version": "6.9.0",
3
+ "version": "6.9.2",
4
4
  "type": "module",
5
5
  "description": "Parse and transform HTML, CSS and JS",
6
6
  "repository": {
@@ -26,9 +26,9 @@
26
26
  "/src/"
27
27
  ],
28
28
  "dependencies": {
29
- "@babel/core": "7.29.0",
30
- "@babel/helper-module-imports": "7.28.6",
31
- "@babel/parser": "7.29.3",
29
+ "@babel/core": "7.29.7",
30
+ "@babel/helper-module-imports": "7.29.7",
31
+ "@babel/parser": "7.29.8",
32
32
  "@jsenv/humanize": "1.7.8",
33
33
  "@jsenv/urls": "2.9.10",
34
34
  "@jsenv/utils": "2.3.1",
@@ -0,0 +1,16 @@
1
+ // "import.meta.<name>" as parsed by acorn: a member expression whose object
2
+ // is the "import.meta" meta property. Returns <name>, or null for any other node.
3
+ export const getImportMetaPropertyName = (node) => {
4
+ if (node.type !== "MemberExpression" || node.computed) {
5
+ return null;
6
+ }
7
+ const { object, property } = node;
8
+ if (
9
+ object.type !== "MetaProperty" ||
10
+ object.meta.name !== "import" ||
11
+ object.property.name !== "meta"
12
+ ) {
13
+ return null;
14
+ }
15
+ return property.name;
16
+ };
@@ -0,0 +1,5 @@
1
+ import { simple } from "acorn-walk";
2
+
3
+ export const visitJsAst = (ast, visitors) => {
4
+ simple(ast, visitors);
5
+ };
package/src/main.js CHANGED
@@ -49,6 +49,8 @@ export { injectJsImport } from "./js/babel_utils.js";
49
49
  export { parseJsWithAcorn } from "./js/parse_js_with_acorn.js";
50
50
  export { parseJsUrls } from "./js/parse_js_urls.js";
51
51
  export { visitJsAstUntil } from "./js/visit_js_ast_until.js";
52
+ export { visitJsAst } from "./js/visit_js_ast.js";
53
+ export { getImportMetaPropertyName } from "./js/import_meta.js";
52
54
  export { getUrlForContentInsideJs } from "./js/js_inline_content_url.js";
53
55
 
54
56
  export { generateUrlForInlineContent } from "./inline_content_url.js";