Skip to content

Commit

Permalink
feat: support import assertions (#417)
Browse files Browse the repository at this point in the history
`acorn-import-attributes` [did not support import assertions
before](#377 (comment)),
but now it does!

This is important because `acorn` is failing to parse `runner.js` in
[this issue](vercel/vercel#11533) due to an
import assertion.
  • Loading branch information
onsclom authored May 10, 2024
1 parent e001d05 commit ddc5cba
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@mapbox/node-pre-gyp": "^1.0.5",
"@rollup/pluginutils": "^4.0.0",
"acorn": "^8.6.0",
"acorn-import-attributes": "^1.9.2",
"acorn-import-attributes": "^1.9.5",
"async-sema": "^3.1.1",
"bindings": "^1.4.0",
"estree-walker": "2.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const acorn = Parser.extend(
//require("acorn-class-fields"),
//require("acorn-static-class-features"),
//require("acorn-private-class-elements")
require('acorn-import-attributes').importAttributes,
require('acorn-import-attributes').importAttributesOrAssertions,
);

import os from 'os';
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions test/unit/import-assertions/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-assertions/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" assert { type: "json" }

export default info
6 changes: 6 additions & 0 deletions test/unit/import-assertions/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"package.json",
"test/unit/import-assertions/foo.js",
"test/unit/import-assertions/info.json",
"test/unit/import-assertions/input.js"
]

0 comments on commit ddc5cba

Please sign in to comment.