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

V2: Fails to resolve wasm file from node module #4839

Closed
xzilja opened this issue Jul 3, 2020 · 4 comments
Closed

V2: Fails to resolve wasm file from node module #4839

xzilja opened this issue Jul 3, 2020 · 4 comments

Comments

@xzilja
Copy link

xzilja commented Jul 3, 2020

🐛 bug report

🎛 Configuration (.babelrc, package.json, cli command)

This is a nested package.json inside a monorepo packages/app/package.json

{
  "name": "my-app",
  "version": "1.0.0",
  "private": true,
  "browser": "dist/index.html",
  "source": "public/index.html",
  "engines": {
    "browsers": "Chrome 80, Safari 13.1"
  },
  "alias": {
    "$app": "./src",
    "$images": "./public/images"
  },
  "scripts": {
    "clean": "rm -rf dist",
    "start": "parcel serve ./public/index.html",
    "build": "yarn clean; parcel build ./public/index.html",
  },
  "dependencies": {
    "stretch-layout": "0.3.2"
  },
  "devDependencies": {}
}

🤔 Expected Behavior

I am importing and using wasm library for https://github.com/vislyhq/stretch, since it says that parcel supports wasm out of the box I expected there to be no build errors.

😯 Current Behavior

When I'm trying to start or build an app I get an error:

🚨 Build failed.
@parcel/core: Failed to resolve './stretch_layout_bg' from './node_modules/stretch-layout/stretch_layout.js'
/Users/ilja/Documents/GitHub/skimitar-tmp/node_modules/stretch-layout/stretch_layout.js:1:23
> 1 | import * as wasm from './stretch_layout_bg';
>   |                       ^^^^^^^^^^^^^^^^^^^^^
  2 | 
  3 | /**
@parcel/resolver-default: Cannot load file './stretchlayout_bg' in './nodemodules/stretch-layout'.

I also tried to slap .wasm on the end of stretchlayout_bg layout thinking that maybe parcel needs it to resolve this correctly, but had no luck:

🚨 Build failed.
Error: No transformers found for "/Users/ilja/Documents/GitHub/skimitar-tmp/nodemodules/stretch-layout/stretch_layoutbg.wasm".

💁 Possible Solution

Not sure, is this functionality implemented in parcel v2 or is it still on the roadmap?

🔦 Context

Trying to use wasm library in parcel, was under assumption this is supported out of the box, but is currently failing.

💻 Code Sample

You can import anything from this library to trigger an error i.e.

import { Allocator, Node } from 'stretch-layout';

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-beta.1
Node 14.4.0
npm/Yarn [email protected]
Operating System [email protected] (Catalina)
@mischnic
Copy link
Member

is it still on the roadmap

Yes, it's unfortunately still not implemented (#647, #1325)

@sighWang
Copy link

can parcel import wasm from node_modules right now?

@XSPGMike
Copy link

XSPGMike commented Mar 14, 2022

looks like it still can't be done, there is no transformer for wasm right now.
you can import the file anyway by prepending url to the wasm file location.
import fileName from 'url:../node_modules/package/file.wasm'

@Yongle-Fu
Copy link

anything update ?

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

5 participants