netlify/build is an opensource monorepo and receives frequent contributions. This constrained us from performing a big bang migration which has the risk of large merge conflicts. The migration had to be transparent, making it possible for devs to add changes without noticing that the underlying tooling was changing.
A package.json file has an
exports property which is a package’s main entry point. Initially the property was
exports: 'src/index.js' because were publishing directly from the src directory but Typescript usually outputs
build files in different directory normally called lib or dist. We used lib in our case. So we used the build script to
simply copy files from src to lib,
build: cp -R src/ lib/ and changed the exports propetry to
exports: lib/index.js. Doing this means devs could keep contributing to the repo without noticing that we are now
publishing from a different directory.
tax in their workflow. We used the
allowJS: true compiler option to allow the building of js files and added
"include": ["src/**/*.ts", "src/**/*.js"] in our tsconfig.json.