Skip to content

Commit

Permalink
Add some newlines for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 28, 2024
1 parent c1ea269 commit b07e688
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions website/blog/2024-02-28-7.24.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ import myConfig from "./config.json" with { type: "json" };
Babel will transform those imports to the appropriate way of loading JSON files in your target platform(s), according to your [`targets`](https://babeljs.io/docs/options#targets) option:
- Modern browsers
```js
const myConfig = await fetch(import.meta.resolve("./config.json")).then(r => r.json());
const myConfig = await fetch(import.meta.resolve("./config.json"))
.then(r => r.json());
```
- Older browsers without `import.meta` support
- Node.js (ESM)
- Node.js (CommonJS)
```js
const myConfig = JSON.parse(require("fs").readFileSync(require.resolve("./config.json")));
const myConfig = JSON.parse(
require("fs").readFileSync(require.resolve("./config.json"))
);
```
- Various combinations of the above
Expand Down

0 comments on commit b07e688

Please sign in to comment.