Skip to content

Commit

Permalink
feat: support import attributes (#377)
Browse files Browse the repository at this point in the history
The [Import Attributes
proposal](https://github.com/tc39/proposal-import-attributes) is in
Stage 3, so implementation is started. Currently, NFT bails on any file
that includes import attributes, because Acorn can't parse them. That's
because Acorn only supports Stage 4 proposals - but for import
attributes, there's a plugin that this PR adds to NFT.
  • Loading branch information
Skn0tt committed Dec 13, 2023
1 parent 6bc3b30 commit 22541e4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@mapbox/node-pre-gyp": "^1.0.5",
"@rollup/pluginutils": "^4.0.0",
"acorn": "^8.6.0",
"acorn-import-attributes": "^1.9.2",
"async-sema": "^3.1.1",
"bindings": "^1.4.0",
"estree-walker": "2.0.2",
Expand Down
1 change: 1 addition & 0 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const acorn = Parser.extend(
//require("acorn-class-fields"),
//require("acorn-static-class-features"),
//require("acorn-private-class-elements")
require("acorn-import-attributes").importAttributes
);

import os from 'os';
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions test/unit/import-attributes/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"foo": "bar"
}
4 changes: 4 additions & 0 deletions test/unit/import-attributes/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import foo from "./foo"
import info from "./info.json" with { type: "json" }

export default info
6 changes: 6 additions & 0 deletions test/unit/import-attributes/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"package.json",
"test/unit/import-attributes/foo.js",
"test/unit/import-attributes/info.json",
"test/unit/import-attributes/input.js"
]
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,11 @@ acorn-globals@^6.0.0:
acorn "^7.1.1"
acorn-walk "^7.1.1"

acorn-import-attributes@^1.9.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/acorn-import-attributes/-/acorn-import-attributes-1.9.2.tgz#bc3765bca6ec0c5c69d2293afd582216215279b0"
integrity sha512-O+nfJwNolEA771IYJaiLWK1UAwjNsQmZbTRqqwBYxCgVQTmpFEMvBw6LOIQV0Me339L5UMVYFyRohGnGlQDdIQ==

acorn-jsx@^5.3.2:
version "5.3.2"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
Expand Down

0 comments on commit 22541e4

Please sign in to comment.