Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
index: use Node's CommonJS JSON loader
- Node natively supports loading JSON via `require()` since 2011, which is a cleaner and easier way to load JSON: https://nodejs.org/en/blog/release/v0.5.2 - Node's `require()` safely performs regular JSON decode whenever it detects a ".json" file extension, which is what our "detectable.json" filename is using. - The `createRequire()` API is only necessary because arRPC is not a CommonJS project. However, if the package.json was changed to `"type": "commonjs"` we would be able to remove those two lines to make the code even cleaner, since `require()` would then be available automatically. - Using `createRequire()` is a completely normal, supported interoperability feature of Node, and is documented here: https://nodejs.org/api/module.html#modulecreaterequirefilename
- Loading branch information