Skip to content

Migrate to Typescript #8

@fayzzzm

Description

@fayzzzm

Hey, pro-js team, hope you are doing well,
It is good that you are writing such a good lib, but you are making serious mistakes of the node module resolution. Here is the thing, when you have a project and you wrote all of the code with ESNEXT (ES6+) and you expect your code should work, but node requires from you what, require() resolving of modules.

What you should do, you can migrate to typescript and write exact good tsconfig for you lib and using Makefile commands such as $(OUT_DIR)/node_modules: mkdir -p $@ ln -s ../lib $@/lib you can create node_modules folder inside of your dist | build folder and then put aliases of your lib folder to node_modules, so each require() will search for nearest node_modules.

NOTE: This type of config is used when your tsconfig has path aliases. The example, you say for every './lib/' should be replaced by 'lib' and when you build this lib stays by not changing it to the previous state as './lib/', cause of that require('lib') searches from nearest node_modules lib. If you are not using the path, then you don't need Makefile config, just write your lib with TS and build it.

Also, you can achieve the same result with webpack.

I hope, I helped you with something.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions