vercel / pkg

Package your Node.js project into an executable
https://npmjs.com/pkg
MIT License
24.3k stars 1.01k forks source link

`may-exclude` and `must-exclude` to README #126

Closed gillez closed 3 years ago

gillez commented 7 years ago

Hi,

I get the following warning when compiling my code:

 Warning Cannot resolve 'config.getServerMode() ? '../libserver/server_code.js' : '../liblocal/local_code.js''
  Use a string literal as argument for 'require', or leave it
  as is and specify the resolved file name in 'scripts' option.

I understand the reason for this and what I need to do. As it says in the manual: your code may have require(variable) calls. Such cases are not handled by pkg. So you must specify the files - scripts and assets - manually in a config.

I have added server_code.js/local_code.js to the "pkg/asset" section of my package.json and the output file works fine. I'm just wondering if there's a way to get rid of the warning message? I.e. can I tell pkg "this line is fine, I've added the file to assets, you don't need to warn me"?

igorklopov commented 7 years ago

You can add 'may-exclude' as a second argument to require. That tells pkg 'this is fine'.

gillez commented 7 years ago

Thanks Igor, that works fine. Great answer. :)

I think it would be worth adding this info to the README file for others in future.

igorklopov commented 7 years ago

I don't like names must-exclude and may-exclude. They do not mean that. The file is not followed rather excluded. It may be included if it is followed from another require or package.json.assets.

igorklopov commented 7 years ago

Also, future-proof and lazy-cache-proof solution is needed like pkg-must-exclude, that ignores if a value does not start with pkg-. https://github.com/jonschlinkert/center-align/blob/0.1.3/utils.js#L28

igorklopov commented 7 years ago

Also, path.resolve similar to path.join

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] commented 3 years ago

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.