Skip to content

Conversation

@deepak0x
Copy link
Contributor

@deepak0x deepak0x commented Jan 4, 2026

  • Replace 'import packageJson from ./package.json assert { type: 'json' }' with readFileSync
  • Fixes build error: SyntaxError: Unexpected identifier 'assert'
  • Affects packages/auth and packages/api rollup.config.js files
  • Uses Node.js fs.readFileSync which is compatible with Rollup parser

Closes #1050

Mac Recording
https://github.com/user-attachments/assets/257f6cb5-2632-4da9-9157-99849ca26934

- Replace 'import packageJson from ./package.json assert { type: 'json' }' with readFileSync
- Fixes build error: SyntaxError: Unexpected identifier 'assert'
- Affects packages/auth and packages/api rollup.config.js files
- Uses Node.js fs.readFileSync which is compatible with Rollup parser
@deepak0x
Copy link
Contributor Author

deepak0x commented Jan 8, 2026

@Spiral-Memory can you please check this pr...

Copy link
Collaborator

@Spiral-Memory Spiral-Memory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix @pratheek56. If possible, could you attach a video showing the build succeeding on Linux, as well as on Windows and Mac if available.

@deepak0x
Copy link
Contributor Author

sure @Spiral-Memory

@Spiral-Memory
Copy link
Collaborator

Spiral-Memory commented Jan 15, 2026

Instead of using reading, which could be a blocking operation, we could use with { type: 'json' } instead of assert. I think that would work just as well and be non-blocking. Please look into that option.

@deepak0x
Copy link
Contributor Author

actually i check and got that readfilesync is good option..
{ type: 'json' } will work too...

@Spiral-Memory
Copy link
Collaborator

Please change to with { type: 'json' }

- Replace readFileSync with 'with { type: 'json' }' import syntax
- Uses newer standard import attributes syntax
Copy link
Collaborator

@Spiral-Memory Spiral-Memory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @deepak0x
Hope build is succeeding ?

@Spiral-Memory
Copy link
Collaborator

It seems this solution isn’t backward compatible with Node 16. Consider trying and explore similar solution:

const require = createRequire(import.meta.url);
const packageJson = requirepackage.json');

This approach provides module caching and ensures backward compatibility.

@deepak0x
Copy link
Contributor Author

deepak0x commented Jan 15, 2026

Hi @Spiral-Memory
The preinstall script requires Node.js v16.19.0.. causing failure during preinstall
should i change this requirement to 16 or greater?

@Spiral-Memory
Copy link
Collaborator

If we switch to Node 16 or higher, it might cause issues for those still using Node 16. That would mean updating the documentation to require Node > 16, but we haven’t fully tested on versions above 16 yet. I’m looking a solution that’s backward compatible, supports module caching (unlike your initial approach), and works with higher Node versions as well.

deepak0x and others added 2 commits January 15, 2026 15:11
…atibility

- Replace 'with { type: 'json' }' import syntax with createRequire approach
- Add fileURLToPath and path.dirname for explicit path resolution
- Ensures backward compatibility with Node.js 16.19.0
- Fixes build error during yarn install postinstall script
- Affects packages/auth and packages/api rollup.config.js files
@deepak0x
Copy link
Contributor Author

@Spiral-Memory i addresses your issue
pls check

Copy link
Collaborator

@Spiral-Memory Spiral-Memory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deepak0x
Copy link
Contributor Author

deepak0x commented Jan 15, 2026

added mac recording...

@Spiral-Memory Spiral-Memory merged commit 1fb4274 into RocketChat:develop Jan 15, 2026
4 checks passed
@Spiral-Memory
Copy link
Collaborator

Thanks for the fix @deepak0x

github-actions bot added a commit that referenced this pull request Jan 15, 2026
@Spiral-Memory Spiral-Memory added chore a subtle fix and removed testing labels Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore a subtle fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails with "SyntaxError: Unexpected identifier 'assert'" in @embeddedchat/auth package

2 participants