Skip to content

Commit

Permalink
Wrap code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Dec 19, 2024
1 parent ab6533d commit fda20e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion utils/website/graphile-config/preset.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,27 @@ You can specify a `graphile.config.ts` file, but if that uses `export default`,
and your TypeScript is configured to export ESM, then you may get an error
telling you that you cannot `require` an ES Module:

<div className="wrapcode">

```
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/graphile.config.ts
require() of ES modules is not supported.
require() of /path/to/graphile.config.ts from /path/to/node_modules/graphile-config/dist/loadConfig.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /path/to/package.json.
```

</div>

Or, in newer versions, an error saying unknown file extension:

```js
<div className="wrapcode">

```
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /path/to/graphile.config.ts
```

</div>

To solve this, use the experimental loaders API to add support for TS ESM via
the `ts-node/esm` loader:

Expand Down
4 changes: 4 additions & 0 deletions utils/website/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
--ifm-color-primary-lightest: #ffffff;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
}

.wrapcode code {
white-space: pre-wrap;
}

0 comments on commit fda20e6

Please sign in to comment.