Skip to content

Commit

Permalink
document typescript module resolution (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
ephys authored Apr 11, 2024
1 parent 1fcd313 commit 341ea81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/_fragments/_decorator-info.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ Using legacy decorators requires to use a transpiler such as [TypeScript](https:
[Babel](https://babeljs.io/docs/babel-plugin-proposal-decorators) or others to compile them to JavaScript.
Alternatively, Sequelize also supports [a legacy approach](../other-topics/legacy-model-definitions.mdx) that does not require using decorators, but this is discouraged.

If you're using TypeScript, you will also need to configure it to be able to resolve this export, [see our Getting Started guide](../getting-started.mdx#typescript) for more information.

:::
12 changes: 12 additions & 0 deletions docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ Head to the [Version Policy page](/releases) to know which versions of TypeScrip
and make sure that the [`@types/node`](https://www.npmjs.com/package/@types/node) package corresponding to your Node.js version is installed
in your project.

:::info

Sequelize makes use of the the [`exports`](https://nodejs.org/api/packages.html#exports) `package.json` field.
You may need to update your `tsconfig.json` configuration to make sure TypeScript's module resolution supports it.

At time of writing (TS 5.4), this can be done in two ways:

- Set [`moduleResolution`](https://www.typescriptlang.org/tsconfig#moduleResolution) to `node16`, `nodenext`, or `bundler`,
- or set [`resolvePackageJsonExports`](https://www.typescriptlang.org/tsconfig#resolvePackageJsonExports) to `true`.

:::

## CommonJS or ESM?

Our documentation makes heavy use of ECMAScript Modules (ESM), but CommonJS is fully supported by Sequelize.
Expand Down

0 comments on commit 341ea81

Please sign in to comment.