svgmoji / svgmoji

Popular open source emoji libraries available as svg sprites
MIT License
69 stars 8 forks source link

Add emoji.json to exports #12

Closed maccman closed 3 years ago

maccman commented 3 years ago

Summary

Currently svgmoji can't be used as a dependency through webpack.

Error

Module not found: Package path ./emoji.json is not exported from package /Users/alex/repos/reflect-mobile-web/node_modules/svgmoji (see exports field in /Users/alex/repos/reflect-mobile-web/node_modules/svgmoji/package.json)
null
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './emoji.json' is not defined by "exports" in /Users/alex/repos/reflect-mobile-web/node_modules/svgmoji/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:513:3)
    at resolveExports (internal/modules/cjs/loader.js:432:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.mod._resolveFilename (/Users/alex/repos/reflect-mobile-web/node_modules/next/dist/build/webpack/require-hook.js:4:1784)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/alex/repos/reflect-mobile-web/node_modules/@team-reflect/reflect-editor/dist/extensions.js:18:38)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Solution

Add emoji.json to exports:

package.json:

  "exports": {
    ".": {
      "import": "./dist/svgmoji.esm.js",
      "require": "./dist/svgmoji.cjs.js",
      "browser": "./dist/svgmoji.browser.esm.js",
      "types": "./dist/svgmoji.cjs.d.ts",
      "default": "./dist/svgmoji.esm.js"
    },
    "./emoji.json": "./emoji.json",
...
ifiokjr commented 3 years ago

Thanks for raising. I've just pushed up a fix and I'll merge and release once all the checks pass.