renova v0.1.0
Overview
renova
patches third-party packages with non-fully-ESM-compliant source and/or TypeScript declaration files (e.g. @apollo/client
) by appending explicit file names and extensions to unqualified export
and import
statements, facilitating nodenext
/node16
+ module resolution of dependencies with legacy exports.
For example, given the following source tree:
directory/
index.js
file.js
Unqualified exports and imports are corrected as follows:
Input
export {foo} from './directory';
import bar from './file';
Output
export {foo} from './directory/index.js';
import bar from './file.js';
Usage
Automatic
š package.json
{
"scripts": {
"dependencies": "renova @apollo/client"
}
}
This will patch @apollo/client
's .d.ts
files whenever dependencies are installed or upgraded.
š” Note that, when run from the dependencies
lifecycle script, no output may be printed. In contrast, postinstall
does allow output but is only executed when installing all dependencies; not when installing or upgrading one or more specific packages.
Manual
$ npx renova [--dry-run] [--extensions=<extension>,...] [--verbose] <package> ...
<package>: Name of a package under ./node_modules to patch, e.g. '@apollo/client'.
--dry-run: Print potential outcome without altering files. Implies --verbose.
--extensions: Comma-separated list of file name extensions to process. Defaults to '.d.ts'.
--verbose: Print all matching exports and imports.
Example
# first-time run
$ npx renova --verbose @apollo/client
./node_modules/@apollo/client/cache/core/cache.d.ts
š ļø ../../utilities ā ../../utilities/index.js
š ļø ./types/DataProxy ā ./types/DataProxy.js
š ļø ./types/Cache ā ./types/Cache.js
...
# safe to run on an already-patched package
$ npx renova --verbose @apollo/client
./node_modules/@apollo/client/cache/core/cache.d.ts
āļø ../../utilities/index.js
āļø ./types/DataProxy.js
āļø ./types/Cache.js
...
2 years ago