0.1.0 • Published 2 years ago

renova v0.1.0

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
2 years ago

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
...
0.1.0

2 years ago