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: Unexpected identifier 'assert' on build #69

Open
hejops opened this issue Feb 4, 2025 · 1 comment · May be fixed by #70
Open

SyntaxError: Unexpected identifier 'assert' on build #69

hejops opened this issue Feb 4, 2025 · 1 comment · May be fixed by #70

Comments

@hejops
Copy link

hejops commented Feb 4, 2025

Node.js removed support for import assertions a while ago, so rollup.config.mjs is technically invalid now. I thought I could work around this by simply replacing assert with with, but rollup still thinks there is an assert somewhere.

I'm on node 23.7.0. Presumably versions >= 22 will be affected.

To reproduce:

cd /tmp
rm -rf discojs
git clone https://github.com/aknorw/discojs
cd discojs
yarn install

yarn rollup --version

yarn build || :
sed -i 's/assert/with/' rollup.config.mjs
yarn build || :
Cloning into 'discojs'...
remote: Enumerating objects: 1150, done.
remote: Counting objects: 100% (217/217), done.
remote: Compressing objects: 100% (116/116), done.
remote: Total 1150 (delta 128), reused 101 (delta 101), pack-reused 933 (from 1)
Receiving objects: 100% (1150/1150), 1.18 MiB | 2.33 MiB/s, done.
Resolving deltas: 100% (762/762), done.
yarn install v1.22.22
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
warning rollup-plugin-ts@3.4.5: The engine "pnpm" appears to be invalid.
warning browserslist-generator@2.1.0: The engine "pnpm" appears to be invalid.
[4/5] Linking dependencies...
warning " > typedoc@0.19.2" has incorrect peer dependency "typescript@3.9.x || 4.0.x".
[5/5] Building fresh packages...
$ husky
Done in 1.20s.
yarn run v1.22.22
$ /tmp/discojs/node_modules/.bin/rollup --version
rollup v4.21.0
Done in 0.16s.
yarn run v1.22.22
$ rimraf dist && rollup -c
[!] SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:338:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:106:18)
    at ModuleLoader.#translate (node:internal/modules/esm/loader:473:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:520:27)
    at ModuleJob._link (node:internal/modules/esm/module_job:115:19)


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.22.22
$ rimraf dist && rollup -c
[!] SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:338:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:106:18)
    at ModuleLoader.#translate (node:internal/modules/esm/loader:473:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:520:27)


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@hejops
Copy link
Author

hejops commented Feb 4, 2025

I figured out that this is due to rollup-plugin-ts, which has been deprecated. @rollup/plugin-typescript seems to be the way to go these days. I'll try writing a PR to fix this.

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