nodejs-mobile / nodejs-mobile

Full-fledged Node.js on Android and iOS
https://nodejs-mobile.github.io
Other
458 stars 44 forks source link

Integrating @js-temporal fail #67

Closed Jonas1024 closed 6 months ago

Jonas1024 commented 6 months ago

Version

18.17.1

Platform

Darwin MacBook-Pro.local 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 x86_64

Subsystem

iOS 17.0; Xcode 15.0.1;

What steps will reproduce the bug?

I want to integrate js-sdk-examples into my project. @js-temporal runs successfully in mac environment.

So I run npm install install related modules in demo native-xcode-node-folder:

    "@0xpolygonid/js-sdk"
    "@0xpolygonid/mongo-storage"
    "@iden3/js-jsonld-merklization"
    "@iden3/js-jwz"
    "dotenv"
    "ethers"

And the main.js:

let http = require('http') 
const index = require("./dist/index");
let server = http.createServer()
server.on('request', (req, res) => {
  let url = req.url
  if (url === '/') {
      index.identityCreation();
  }
}

server.listen(3005, () => {
  console.log('Run......')
})

But, when I run the app, it crash:

Warning: disabling flag --expose_wasm due to conflicting flags
/Users/mac/Library/Developer/CoreSimulator/Devices/5DDA72EA-8BA1-45A9-A5FB-10D1854AE0BF/data/Containers/Bundle/Application/35F25EF8-6FBD-43B3-808A-6841E32D8182/native-xcode-node-folder.app/nodejs-project/node_modules/@js-temporal/polyfill/dist/index.cjs:1
...
...
...
SyntaxError: Invalid regular expression: /[^-0-9 \p{L}]/: Invalid property name in character class
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/Users/mac/Library/Developer/CoreSimulator/Devices/5DDA72EA-8BA1-45A9-A5FB-10D1854AE0BF/data/Containers/Bundle/Application/35F25EF8-6FBD-43B3-808A-6841E32D8182/native-xcode-node-folder.app/nodejs-project/node_modules/@iden3/js-jsonld-merklization/dist/node/cjs/lib/mt-value.js:7:20)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)

Node.js v18.17.1

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

N/A

Additional information

No response

staltz commented 6 months ago

Hi! Thanks for all the details in your issue, this helps a lot since I immediately know what's the root cause here.

Regex Property Names like \p{L} are unsupported in Node.js Mobile. I just now updated the docs website to inform that, as well as what kind of solutions you can do instead: https://nodejs-mobile.github.io/docs/api/differences/#regexp-unicode-property-names