ilearnio / module-alias

Register aliases of directories and custom module paths in Node
MIT License
1.76k stars 69 forks source link

Add "module-alias" to package.json #50

Open ilearnio opened 5 years ago

ilearnio commented 5 years ago

Right now we have _moduleAliases and _moduleDirectories options that we read from package.json. It makes sense to move them into "module-alias": { alias, modules } (names alias, modules can be different, just took them from WebPack https://webpack.js.org/configuration/resolve/)

mfaheemakhtar commented 5 years ago

@ilearnio, I'm taking this issue. Can I?

There is an alternative way too, instead of using the package.json file. We can use ".module-alias-rc" or something similar like ".babelrc" and ".prettierrc".

Thoughts?

ilearnio commented 5 years ago

@mfaheemakhtar Sure. That would be great! .module-alias-rc is also a good idea, it could contain JSON object with aliases, modulesDirectories.

It makes sense to move them into "module-alias": { alias, modules } (names alias, modules can be different, just took them from WebPack)

I said this earlier but now I think it would be more clear if the properties would be called aliases and moduleDirectories, in both package.json or rc file

theomjones commented 5 years ago

Would also be nice to be able to define for different environments in this config

{
    "development": {
        "aliases": [...]
    },
   //  ...
}
gokberkakdeniz commented 5 years ago

moduleAliases_, _moduleDirectories and any other option starting with underscore is ignored in auto-generated package.json (in app.asar) by electron-builder. I think it is better to use module-alias option, or any options that is not starting with underscore, instead of moduleAliases_.

Related issue: Auto generated package.json does not contain settings starting with undersore