Reputation: 19
We are creating an npm package used in a node environment and written in Typescript. We would like to upgrade our dependencies in our node_modules folder for our npm package to use the latest versions. There are some dependencies where the latest versions are written strictly as es6 modules. The issue is that we must use a commonjs module system in our npm package so that we can use the --require flag in our nextWorkDev script to execute our code before specific executables run. Unfortunately, we can not import es6 modules into commonjs files without transpiling the code to commonjs or using a dynamic import (does not work because of the asynchronous nature).
My question is: Is there a way that we can transpile the dependencies that are es6 only modules to commonjs and include these modules in our npm build that gets published to the npm registry?
I have looked at babel and webpack documentation to see if we could bundle and transpile our code and its dependencies into one file to ship as a single commonjs module. I have also tried to transpile specific modules within the node_modules folder and include these modules in the files array of our package.json to include in the npm build. I was expecting that the transpiled node modules would be included in the build, but they were not. Also, I am not sure if babel will transpile the node modules correctly.
Upvotes: 0
Views: 312