Skip to content

Commit

Permalink
feat: add support for import attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton authored and amaanq committed Feb 1, 2024
1 parent 1280c10 commit b454f16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ module.exports = grammar({
seq($.import_clause, $._from_clause),
field('source', $.string),
),
optional($.import_attribute),
$._semicolon,
),

Expand Down Expand Up @@ -234,6 +235,8 @@ module.exports = grammar({
),
),

import_attribute: $ => seq('with', $.object),

//
// Statements
//
Expand Down
5 changes: 5 additions & 0 deletions test/corpus/statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import defaultMember, { member1, member2 as alias2 } from "module-name";
import defaultMember, * as name from "module-name";
import "module-name";
import { member1 , member2 as alias2, } from "module-name";
import pkg from "./package.json" with { type: "json" };
import("a");
import("a").then((m) => {});
import.meta.url;
Expand Down Expand Up @@ -157,6 +158,10 @@ import { b } from
(identifier))))
(string
(string_fragment)))
(import_statement
(import_clause (identifier)) (string (string_fragment))
(import_attribute (object
(pair (property_identifier) (string (string_fragment))))))
(expression_statement
(call_expression
(import)
Expand Down
4 changes: 4 additions & 0 deletions test/highlight/imports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import pkg from "./package.json" with { type: "json" };
// <- keyword
// ^ string
// ^ keyword

0 comments on commit b454f16

Please sign in to comment.