nats-io / nats.ts

TypeScript Node.js client for NATS, the cloud native messaging system
https://www.nats.io
Apache License 2.0
178 stars 13 forks source link

Package.json error during webpack bundling #80

Closed avatarneil closed 4 years ago

avatarneil commented 4 years ago

I see that there have been recent changes in the resolution of the package version. Unfortunately, it appears that the current method of resolving the package version presents issues when attempting to compile using Webpack. When bundling a package that uses ts-nats, there is a warning from Webpack:

arbitrary-package:     WARNING in /arbitrary-package/node_modules/ts-nats/lib/nats.js 41:18-34
arbitrary-package:     Critical dependency: the request of a dependency is an expression

At runtime, for the bundled package, this presents the following:

Error: Cannot find module '//../../package.json'
    at r (/arbitrary-package/index.js:369:282738)
    at Object.<anonymous> (/arbitrary-package/index.js:83:36019)
    at Object.<anonymous> (/arbitrary-package/index.js:83:39628)
    at r (/arbitrary-package/index.js:1:158)
    at Object.<anonymous> (/arbitrary-package/index.js:369:250401)
    at r (/arbitrary-package/index.js:1:158)
    at Object.<anonymous> (/arbitrary-package/index.js:369:249991)
    at r (/arbitrary-package/index.js:1:158)
    at Object.<anonymous> (/arbitrary-package/index.js:369:249517)
    at r (/arbitrary-package/index.js:1:158)
    at Object.<anonymous> (/arbitrary-package/index.js:369:249004)
    at r (/arbitrary-package/index.js:1:158)
    at Object.<anonymous> (/arbitrary-package/index.js:170:257317)
    at r (/arbitrary-package/index.js:1:158)
    at Object.<anonymous> (/arbitrary-package/index.js:362:203591)
    at r (/arbitrary-package/index.js:1:158) {
  code: 'MODULE_NOT_FOUND'
}

I think the issue may be an extraneous / in the path for the package.json, in nats.js for example, it appears to use the path ../package.json instead of the /../package.json path used in this library.