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

cannot transform @code-hike/lighter #49

Closed
himself65 opened this issue Jan 17, 2024 · 5 comments
Closed

cannot transform @code-hike/lighter #49

himself65 opened this issue Jan 17, 2024 · 5 comments

Comments

@himself65
Copy link

Related: code-hike/lighter#35

@himself65
Copy link
Author

@himself65
Copy link
Author

/Users/himself65/Library/Caches/fnm_multishells/85522_1705359274939/bin/npm run build

> [email protected] build
> node ./build.js

vite v5.0.11 building for production...
✓ 3 modules transformed.
Unexpected eof (Note that you need plugins to import files that are not JavaScript)
file: /Users/himself65/Code/vite-issue/node_modules/@code-hike/lighter/dist/onig.wasm?module:1:5
1: asm�`���`��`����`�����``������`���`��`�������`��������``   �������������������``...
        ^
2: 
3:      
node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^

Error [RollupError]: Unexpected eof
    at error (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
    ... 6 lines matching cause stack trace ...
    at async ModuleLoader.addModuleSource (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/node-entry.js:17760:13) {
  cause: Error [RollupError]: Unexpected eof
      at error (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
      at nodeConverters (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/parseAst.js:2084:9)
      at convertNode (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/parseAst.js:969:12)
      at convertProgram (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/parseAst.js:960:48)
      at parseAstAsync (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/parseAst.js:2150:20)
      at async Module.tryParseAsync (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/node-entry.js:13514:21)
      at async Module.setSource (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/node-entry.js:13095:35)
      at async ModuleLoader.addModuleSource (file:///Users/himself65/Code/vite-issue/node_modules/rollup/dist/es/shared/node-entry.js:17760:13) {
    code: 'PARSE_ERROR',
    pos: 5
  },
  code: 'PARSE_ERROR',
  id: '/Users/himself65/Code/vite-issue/node_modules/@code-hike/lighter/dist/onig.wasm?module',
  pos: 5,
  loc: {
    column: 5,
    file: '/Users/himself65/Code/vite-issue/node_modules/@code-hike/lighter/dist/onig.wasm?module',
    line: 1
  },
  frame: '1: \x00asm\x01\x00\x00\x00\x01�\x01\x16`\x02\x7F\x7F\x01\x7F`\x01\x7F\x01\x7F`\x03\x7F\x7F\x7F\x01\x7F`\x04\x7F\x7F\x7F\x7F\x01\x7F`\x01\x7F\x00`\x05\x7F\x7F\x7F\x7F\x7F\x01\x7F`\x03\x7F\x7F\x7F\x00`\x02\x7F\x7F\x00`\x06\x7F\x7F\x7F\x7F\x7F\x7F\x01\x7F`\x07\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x01\x7F`\x00\x01\x7F`\t\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x01\x7F`\b\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x01\x7F`\x00\x00`\x04...\n' +
    '        ^\n' +
    '2: \x01\x00\x01\x00\x03\x03\x02\x00\x00\x02\x06\x02\x0E\x02\x01\x0F\x01\x01\x01\n' +
    '3: \x13\x02\x05\t\x06\x01\x0E\x14\x15\x10\x07\x03\x02\x01\x00\x01\x04',
  watchFiles: [
    '/Users/himself65/Code/vite-issue/src/index.ts',
    '/Users/himself65/Code/vite-issue/package.json',
    '/Users/himself65/Code/vite-issue/node_modules/@code-hike/lighter/dist/worker.esm.mjs',
    '/Users/himself65/Code/vite-issue/node_modules/@code-hike/lighter/dist/onig.wasm'
  ]
}

Node.js v20.10.0

Process finished with exit code 1


@Menci
Copy link
Owner

Menci commented Jan 18, 2024

image

Seems the package is importing WASM with ?module, which won't be handled by this plugin...

@himself65
Copy link
Author

is this expected?

@Menci
Copy link
Owner

Menci commented Jan 19, 2024

Yes. It's ignored since it has the unexpected suffix ?module, which in non-standard (notice my log prefixed with *****):

image

However, after patching the package to remove the ?module suffix, it still fails to build:

image

The WASM file, treated as ES Module, is requesting a non-existing module import env.

image

We can see that it's not following WebAssembly ESM integration. So, it's not suitable for this plugin.

@Menci Menci closed this as completed Jan 19, 2024
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

No branches or pull requests

2 participants