Skip to content

Rollup can't interpret annotation "/*#__PURE__*/ #157

@wighawag

Description

@wighawag

Check existing issues

Ox Version

0.11.3

Current Behavior

The issue is the similar to #50 but I assume it arise from a different reason

I get warning like

../node_modules/.pnpm/ox@0.11.3_typescript@5.9.3_zod@4.3.5/node_modules/ox/_esm/core/Base64.js (6:27): A comment

"/*#__PURE__*/"

in "../node_modules/.pnpm/ox@0.11.3_typescript@5.9.3_zod@4.3.5/node_modules/ox/_esm/core/Base64.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.

Expected Behavior

I expect to have no warning when usinx 0x or its dependent

Steps To Reproduce

I am using a complex application but this seems to be just vite + ox

Link to Minimal Reproducible Example

No response

Anything else?

I can fix it by replacing

const characterToInteger = /*#__PURE__*/ {
  ...Object.fromEntries(
    Array.from(
      'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
    ).map((a, i) => [a.charCodeAt(0), i]),
  ),
  ['='.charCodeAt(0)]: 0,
  ['-'.charCodeAt(0)]: 62,
  ['_'.charCodeAt(0)]: 63,
}

with

const characterToInteger = /*#__PURE__*/ (() => ({
  ...Object.fromEntries(
    Array.from('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/')
      .map((a, i) => [a.charCodeAt(0), i])
  ),
  ['='.charCodeAt(0)]: 0,
  ['-'.charCodeAt(0)]: 62,
  ['_'.charCodeAt(0)]: 63,
}))();

It seems rollup have issue with the parsing of the complex structure, wrapping it in a direct function call solve it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions