We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No error when using import attributes to import a JSON file (ESM).
node --trace-warnings --loader=import-in-the-middle/hook.mjs index.mjs
(node:40984) Warning: Error: 'import-in-the-middle' failed to wrap 'file:///.../iitm-test/index.mjs' at getSource (...\iitm-test\node_modules\import-in-the-middle\hook.js:431:21) at async load (...\iitm-test\node_modules\import-in-the-middle\hook.js:446:26) ... 2 lines matching cause stack trace ... at async handleMessage (node:internal/modules/esm/worker:199:18) { cause: Error: Failed to parse 'file:///.../iitm-test/index.mjs' at getExports (...\iitm-test\node_modules\import-in-the-middle\lib\get-exports.js:123:17) at async processModule (...\iitm-test\node_modules\import-in-the-middle\hook.js:198:23) at async getSource (...\iitm-test\node_modules\import-in-the-middle\hook.js:395:25) at async load (...\iitm-test\node_modules\import-in-the-middle\hook.js:446:26) at async nextLoad (node:internal/modules/esm/hooks:748:22) at async Hooks.load (node:internal/modules/esm/hooks:385:20) at async handleMessage (node:internal/modules/esm/worker:199:18) { cause: SyntaxError: Unexpected token (1:31) at pp$4.raise (...\iitm-test\node_modules\acorn\dist\acorn.js:3646:15) at pp$9.unexpected (...\iitm-test\node_modules\acorn\dist\acorn.js:772:10) at pp$9.semicolon (...\iitm-test\node_modules\acorn\dist\acorn.js:749:68) at Parser.parseImport (...\iitm-test\node_modules\acorn-import-attributes\lib\index.js:242:12) at pp$8.parseStatement (...\iitm-test\node_modules\acorn\dist\acorn.js:948:51) at pp$8.parseTopLevel (...\iitm-test\node_modules\acorn\dist\acorn.js:829:23) at Parser.parse (...\iitm-test\node_modules\acorn\dist\acorn.js:601:17) at Function.parse (...\iitm-test\node_modules\acorn\dist\acorn.js:651:37) at getEsmExports (...\iitm-test\node_modules\import-in-the-middle\lib\get-esm-exports.js:37:23) at getExports (...\iitm-test\node_modules\import-in-the-middle\lib\get-exports.js:105:14) { pos: 31, loc: [Position], raisedAt: 35 } } }
Create a project with the following contents
{ "name": "iitm-import-attributes", "version": "1.0.0", "main": "index.mjs", "type": "module", "scripts": { "start": "node --trace-warnings --loader=import-in-the-middle/hook.mjs index.mjs" }, "author": "", "license": "ISC", "description": "", "dependencies": { "import-in-the-middle": "^1.12.0" } }
import json from './test.json' with { type: 'json' }; console.log(json);
{}
npm run start
NodeJS: 22.13.1 NPM: 10.9.2
22.13.1
10.9.2
The text was updated successfully, but these errors were encountered:
I guess this is a duplicate of #105
Sorry, something went wrong.
Is it possible to update acorn? It seems the latest version supports import attributes.
acorn
No branches or pull requests
Expected Behavior
No error when using import attributes to import a JSON file (ESM).
Actual Behavior
node --trace-warnings --loader=import-in-the-middle/hook.mjs index.mjs
Steps to Reproduce the Problem
Create a project with the following contents
package.json
index.mjs
test.json
Run the project
npm run start
Specifications
NodeJS:
22.13.1
NPM:
10.9.2
The text was updated successfully, but these errors were encountered: