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

test/hook/v18-static-import-assert.mjs fails with SyntaxError: Unexpected identifier 'assert' with Node.js 22 #73

Closed
richardlau opened this issue Apr 30, 2024 · 0 comments · Fixed by #81

Comments

@richardlau
Copy link
Member

richardlau commented Apr 30, 2024

Expected Behavior

Test suite passes with Node.js 22.

Actual Behavior

not ok 21 test/hook/v18-static-import-assert.mjs
   ---
   stdout: ''
   stderr: >-
     file:///home/iojs/tmp/citgm_tmp/57e69ae9-aca1-49ae-aae0-acf7ab1693e1/import-in-the-middle/test/fixtures/json.mjs:5
     import coolFile from './something.json' assert { type: 'json' }
                                             ^^^^^^
     SyntaxError: Unexpected identifier 'assert'
         at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
         at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
         at callTranslator (node:internal/modules/esm/loader:416:14)
         at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30)
     Node.js v22.0.0
   ...

Steps to Reproduce the Problem

This is seen in CITGM runs for Node.js 22 (and main) where support for import assertions has been removed, replaced by import attributes.
e.g. https://ci.nodejs.org/job/citgm-smoker/3421/nodes=rhel8-x64/testReport/junit/(root)/citgm/import_in_the_middle_v1_7_3/

This appears to be coming from the fixture:
https://github.com/DataDog/import-in-the-middle/blob/00b01fff1f5b69dd25e307593ec54d1d8abb4844/test/fixtures/json.mjs#L5

At first glance it looks fairly simple to update the fixture (replace assert with with) but it seems like the GitHub Actions here test on a selection of older Node.js 18 and 20 releases which do not have support for import attributes.

FTR support for import attributes landed in Node.js 18 in 18.20.0 and Node.js 20 in 20.10.0. There are no plans to remove import assertions from Node.js 18 or 20.

Specifications

  • Version:
  • Platform:
  • Subsystem:
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

Successfully merging a pull request may close this issue.

1 participant