sibelius / ast-i18n

Easily migrate your existing React codebase to use i18n
MIT License
215 stars 18 forks source link

Missing lib folder on published package #61

Closed renanmav closed 4 years ago

renanmav commented 4 years ago

The problem

I have installed this package from npm with yarn add ast-i18n.

Tried to execute the cli with yarn ast-i18n --src=packages/web/src and end up with this:

yarn ast-i18n --src=packages/web/src
yarn run v1.19.1
$ /Users/renan/www/foton/confy/node_modules/.bin/ast-i18n --src=packages/web/src
internal/modules/cjs/loader.js:775
    throw err;
    ^

Error: Cannot find module '../lib/cli.js'
Require stack:
- /Users/renan/www/foton/confy/node_modules/ast-i18n/bin/cli
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/Users/renan/www/foton/confy/node_modules/ast-i18n/bin/cli:3:1)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:999:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/renan/www/foton/confy/node_modules/ast-i18n/bin/cli' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The why's

The cli is as follows.

#!/usr/bin/env node
require('../lib/cli.js').run();

Checking the node_modules folder I see this:

image

There isn't such lib folder. We should generate it along with its type declarations and minified version.

anikethsaha commented 4 years ago

Here is the fix

In package.json in the main property need to add lib/index.js And also need to add,

 "files": [
    "lib"
  ],

And publish it. The binary will come as usual, as it is already addressed here https://github.com/sibelius/ast-i18n/blob/master/package.json#L5

Also, rm is not present in the dev dep so, need to add that too.