rollup-plugin-ts icon indicating copy to clipboard operation
rollup-plugin-ts copied to clipboard

Deprecated Import Assert in Node.js 22

Open threeal opened this issue 1 year ago • 2 comments

  • Version: 3.4.5
  • Rollup Version: 4.21.2
  • ~~Operating System and version (if applicable):~~
  • Node Version (if applicable): v22.7.0
  • ~~Does it work with tsc (if applicable):~~

Reproduction

Import rollup-plugin-ts using ESM, either in rollup.config.js or anywhere like this:

import ts from "rollup-plugin-ts";

This issue seems related to https://github.com/rollup/rollup/issues/5531.

Expected Behavior

Should import normally, in the case of Rollup, it should bundle file successfully.

Actual Behavior

When bundle file using Rollup:

[!] 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:436:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:442:30)

When imported in any JavaScript file:

import * as compatData from '@mdn/browser-compat-data' 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:436:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:442:30)

Node.js v22.7.0

threeal avatar Sep 09 '24 08:09 threeal

Looks like it's from here:

❯ ag -u "' assert {" -G ".js$"
node_modules/.pnpm/[email protected]/node_modules/browserslist-generator/dist/esm/index.js
3:import * as compatData from '@mdn/browser-compat-data' assert { type: 'json' };

NullVoxPopuli avatar Oct 06 '24 05:10 NullVoxPopuli

https://github.com/wessberg/browserslist-generator/issues/18

NullVoxPopuli avatar Oct 06 '24 05:10 NullVoxPopuli