diff options
author | 2023-03-21 02:51:24 +0000 | |
---|---|---|
committer | 2023-03-20 19:51:24 -0700 | |
commit | 2503b3409eb4725e791819dd509473bcf759fc86 (patch) | |
tree | 53872a6f1f9f62753a901e571a000072d30c6bd8 | |
parent | 6539f66642e71c7e23cbf5a816bd65dd6a0ff7db (diff) | |
download | bun-2503b3409eb4725e791819dd509473bcf759fc86.tar.gz bun-2503b3409eb4725e791819dd509473bcf759fc86.tar.zst bun-2503b3409eb4725e791819dd509473bcf759fc86.zip |
docs: update moduleResolution to bundler (#2429)
* docs: update moduleResolution to bundler
* docs: bundler as well
* Updates
---------
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
-rw-r--r-- | .vscode/settings.json | 12 | ||||
-rw-r--r-- | docs/ecosystem/typescript.md | 9 | ||||
-rw-r--r-- | packages/bun-types/README.md | 16 | ||||
-rw-r--r-- | packages/bun-types/tsconfig.json | 2 | ||||
-rw-r--r-- | tsconfig.json | 2 |
5 files changed, 24 insertions, 17 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index b535a1bd5..35df87e4c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,7 +7,10 @@ "search.followSymlinks": false, "search.useIgnoreFiles": true, "zig.buildOnSave": false, - "zig.buildArgs": ["obj", "-Dfor-editor"], + "zig.buildArgs": [ + "obj", + "-Dfor-editor" + ], "zig.buildOption": "build", "zig.buildFilePath": "${workspaceFolder}/build.zig", "[zig]": { @@ -206,5 +209,8 @@ }, "cmake.configureOnOpen": false, "C_Cpp.errorSquiggles": "Enabled", - "eslint.workingDirectories": ["packages/bun-types"] -} + "eslint.workingDirectories": [ + "packages/bun-types" + ], + "files.insertFinalNewline": true +}
\ No newline at end of file diff --git a/docs/ecosystem/typescript.md b/docs/ecosystem/typescript.md index 43fc2b322..dfedfb850 100644 --- a/docs/ecosystem/typescript.md +++ b/docs/ecosystem/typescript.md @@ -28,6 +28,8 @@ Bun's runtime implements [modern ECMAScript features](https://github.com/sudheer These are the recommended `compilerOptions` for a Bun project. +> The config below sets `moduleResolution` to `bundler` which requires TypeScript option is set to `"bundler"` to support [path mapping](#path-mapping). + ```jsonc { "compilerOptions": { @@ -35,10 +37,13 @@ These are the recommended `compilerOptions` for a Bun project. "lib": ["esnext"], "module": "esnext", "target": "esnext", - "moduleResolution": "nodenext", + + // requires typescript 5.x+ + // use "nodenext" for earlier versions + "moduleResolution": "bundler", // support JSX, CommonJS - "jsx": "preserve", // support JSX (value doesn't matter) + "jsx": "react-jsx", // support JSX (value doesn't matter) "allowJs": true, // allow importing `.js` from `.ts` "esModuleInterop": true, // allow default imports for CommonJS modules diff --git a/packages/bun-types/README.md b/packages/bun-types/README.md index 5aacbb16f..fc4128388 100644 --- a/packages/bun-types/README.md +++ b/packages/bun-types/README.md @@ -19,17 +19,13 @@ bun add bun-types Add this to your `tsconfig.json` or `jsconfig.json`: -```jsonc -{ - "compilerOptions": { - "lib": ["ESNext"], - "module": "ESNext", - "target": "ESNext", - "moduleResolution": "Node", - // "bun-types" is the important part - "types": ["bun-types"] +```jsonc-diff + { + "compilerOptions": { + // ... ++ "types": ["bun-types"] + } } -} ``` # Contributing diff --git a/packages/bun-types/tsconfig.json b/packages/bun-types/tsconfig.json index 644fb4587..e346b31b4 100644 --- a/packages/bun-types/tsconfig.json +++ b/packages/bun-types/tsconfig.json @@ -19,4 +19,4 @@ "./node_modules/*", "./node_modules/@types/node/index.d.ts" ] -}
\ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index 461fdb472..272fd944a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,4 +26,4 @@ "test/snapshots-no-hmr", "node_modules" ] -}
\ No newline at end of file +} |