Skip to content
New issue

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

SyntaxError when importing a JSON file using { type: 'json' } #110

Closed
inaiat opened this issue Jun 18, 2024 · 3 comments
Closed

SyntaxError when importing a JSON file using { type: 'json' } #110

inaiat opened this issue Jun 18, 2024 · 3 comments

Comments

@inaiat
Copy link

inaiat commented Jun 18, 2024

Expected Behavior

The import statement should successfully import the JSON file.

Actual Behavior

A "SyntaxError" is thrown.

Steps to Reproduce the Problem

  1. Import json file using with specific syntax ( with { type: 'json'} ):
    import data from './data.json' with { type: 'json' };
  2. So I updated import-in-the-middle to 1.8.0 (Note that this works fine on version 1.7.3)
  3. After running project I gettting this error:
    { "type": "SyntaxError", "message": "Unexpected token (1:818) at SyntaxError: Unexpected token (1:818)", "stack": SyntaxError: Unexpected token (1:818) at pp$4.raise (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:3586:15) at pp$9.unexpected (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:772:10) at pp$9.semicolon (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:749:68) at Parser.parseImport (/Users/inaiat/app/node_modules/.pnpm/[email protected][email protected]/node_modules/acorn-import-attributes/lib/index.js:242:12) at pp$8.parseStatement (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:948:51) at pp$8.parseTopLevel (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:829:23) at Parser.parse (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:601:17) at Function.parse (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:651:37) at getEsmExports (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/import-in-the-middle/lib/get-esm-exports.js:37:23) at getExports (/Users/inaiat/app/node_modules/.pnpm/[email protected]/node_modules/import-in-the-middle/lib/get-exports.js:73:12) "pos": 818, "loc": { "line": 1, "column": 818 }, "raisedAt": 822 }

Specifications

  • Version: 1.8.0
  • Platform: macOS Apple Silicon / Debian
  • Subsystem: nodejs version 22.3.0
@timfish
Copy link
Contributor

timfish commented Jun 18, 2024

This was fixed by #104

@inaiat
Copy link
Author

inaiat commented Jun 18, 2024

@timfish Thanks!

@timfish
Copy link
Contributor

timfish commented Jun 28, 2024

This is a duplicate of #105 but #104 does help work around the issue

@timfish timfish closed this as completed Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants