tuananh / camaro

camaro is an utility to transform XML to JSON, using Node.js binding to native XML parser pugixml, one of the fastest XML parser around.
MIT License
556 stars 29 forks source link

Module not found: Can't resolve xxxx #100

Closed harpal-hp closed 4 years ago

harpal-hp commented 4 years ago

Describe the bug using serverless framework and trying to transform the xml using template. getting error Module not found for asm2wasm, env, global, along with below error - WebAssembly module is included in initial chunk. This is not allowed, because WebAssembly download and compilation must happen asynchronous. Add an async splitpoint (i. e. import()) somewhere between your entrypoint and the WebAssembly module:

Minimal Script To Reproduce running sls offline in serverless project


const { transform } = require('camaro')
// your code
  let result = await transform(data, {
     data : ['xxx,xxx', {
          processDate: 'xxx',
          effectiveDate: 'xxx',
          tranSubCode: 'xxxx',
}]
[camaro-issue.txt](https://github.com/tuananh/camaro/files/4531879/camaro-issue.txt)

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

- camaro version: 4.1 , 4.2 
- Node version:  10.x , 12.x
- Operating system: win10
harpal-hp commented 4 years ago

Issue is with only server-less framework node JS lambda project, working fine with plain node JS project

tuananh commented 4 years ago

Can you create a minimal repro repo so that I can clone and check the error? Also, what command to use to reproduce it.

tuananh commented 4 years ago

It seems to be problem with serverless framework where it tries to parse wasm file. The way I can see is either config serverless to not to do that. Or I can fix it at camaro project where I remove wasm file and place its content directly in js file.

Just my hypothesis.

tuananh commented 4 years ago

@harpal-hp this looks similar with this issue. update the webpack config to ignore wasm.

https://github.com/serverless-heaven/serverless-webpack/issues/386

harpal-hp commented 4 years ago

Ok, i will try to do that. i have created the repo if you want to replicate the issue -

https://github.com/harpal-sgh/serverless-camaro

Run : npm i then sls offline, you might have to install serverless if not installed already

harpal-hp commented 4 years ago

I tried ignoring .wasm file, but i am losing serverless-bundle capabilities. i have to bundle it using web-pack. If you can do something in Camaro project, it will be great help for everyone, who want to use Camaro library with server-less framework.

Thanks

tuananh commented 4 years ago

I tried ignoring .wasm file, but i am losing serverless-bundle capabilities. i have to bundle it using web-pack. If you can do something in Camaro project, it will be great help for everyone, who want to use Camaro library with server-less framework.

Thanks

it's possible. lemme take a look into it.

harpal-hp commented 4 years ago

@tuananh do you know how long it will take to fix this?

tuananh commented 4 years ago

@harpal-hp i'm working on it. thought it would be straight forward but somehow, it still doesn't work yet :D. maybe another week or two, depends on how i can manage my time.

tuananh commented 4 years ago

Recently, I chose to use worker_threads for performance gain so web support is dropped.

i'm looking for way to re-add it in the future but I don't know how yet. So this won't be fixed anytime soon.

jonsherrard commented 4 years ago

For googlers:

Just a not that worker_threads means this won't work on platforms that don't support Node 12. For example Google Cloud Functions.

(Check node -v locally if you're having working errors)