remusao/tldts

tslib hidden dependency

osdiab opened this issue · 6 comments

I tried to use the metascraper-clearbit package, which depends on tldts. However, it failed with MODULE_NOT_FOUND when you try to run it, because tslib wasn't present. After running yarn install tslib, it then works.

Is tslib a runtime requirement of this library, even if you're not using TypeScript? Not a big deal for me because I do, but thought you should be aware.

Full error internal/modules/cjs/loader.js:626 throw err; ^

Error: Cannot find module 'tslib'
Require stack:

  • /Users/omardiab/code/open-source/metascraper-demo/node_modules/tldts/build/cjs/index.js
  • /Users/omardiab/code/open-source/metascraper-demo/node_modules/metascraper-clearbit/index.js
  • /Users/omardiab/code/open-source/metascraper-demo/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object. (/Users/omardiab/code/open-source/metascraper-demo/node_modules/tldts/build/cjs/index.js:3:15)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/Users/omardiab/code/open-source/metascraper-demo/node_modules/tldts/build/cjs/index.js',
    '/Users/omardiab/code/open-source/metascraper-demo/node_modules/metascraper-clearbit/index.js',
    '/Users/omardiab/code/open-source/metascraper-demo/index.js'
    ]
    }

Hi @osdiab,

Thanks a lot for opening an issue, this is definitely not expected. I tried to not rely on tslib at all but it seems I might have let something split through. Will check now and fix it.

Rémi

That's a great suggestion! I'll have a look. Thanks a lot

Ah I actually take that back (I deleted the post but maybe should have just put a strikethrough lol) because the actual code doesn't show any references to tslib anyway.

The file it seems to show up in is here: tldts-core/build/cjs/src/factory.js

For posterity I suggested using ESLint with eslint-plugin-import to catch any references to stuff not in dependencies, but I don't think the linter would catch this since it doesn't seem to be an explicit dependency on tslib.

@osdiab Yes, seems like a tslib helper is required in commonjs modules for default imports/exports. Will make sure it's fixed today.

Fixed in #207

Released https://github.com/remusao/tldts/releases/tag/v5.3.2. Thanks again for opening the issue!