Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fixtures/tsconfig/tsconfig_broken.json
fixtures/enhanced_resolve/test/fixtures/incorrect-package/pack1/package.json
fixtures/enhanced_resolve/test/fixtures/tsconfig-paths/malformed-json/tsconfig.json
pnpm-lock.yaml
**/.pnp.cjs
**/.pnp.cjs
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ The options are aligned with [enhanced-resolve](https://github.com/webpack/enhan

### Other Options

| Field | Default | Description |
| ------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tsconfig | None | TypeScript related config for resolver |
| tsconfig.configFile | | A relative path to the tsconfig file based on `cwd`, or an absolute path of tsconfig file. |
| tsconfig.references | `[]` | - 'auto': inherits from TypeScript config <br/> - `string []`: relative path (based on directory of the referencing tsconfig file) or absolute path of referenced project's tsconfig |
| enablePnp | false | Enable Yarn Plug'n'Play support |
| Field | Default | Description |
| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| tsconfig | None | TypeScript related config for resolver |
| tsconfig.configFile | | A relative path to the tsconfig file based on `cwd`, or an absolute path of tsconfig file. |
| tsconfig.references | `[]` | - 'auto': inherits from TypeScript config <br/> - `string []`: relative path (based on directory of the referencing tsconfig file) or absolute path of referenced project's tsconfig |
| enablePnp | false | Enable Yarn Plug'n'Play support |

In the context of `@rspack/resolver`, the `tsconfig.references` option helps isolate the `paths` configurations of different TypeScript projects.
This ensures that path aliases defined in one TypeScript project do not unintentionally affect the resolving behavior of another.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@exports-field/bad-specifier",
"version": "1.0.0",
"exports": {
".": [
"",
"./a/../b/../../pack1/index.js",
"././-bad-specifier-",
"-bad-specifier-",
"file.js",
"./a.js?foo=../"
],
"./foo/*": [
"",
"./a/../b/../../pack1/index.js",
"././-bad-specifier-",
"-bad-specifier-",
"file.js",
"./a.js?foo=../#../"
],
"./bar": "-bad-specifier-",
"./baz": ["-bad-specifier-"],
"./baz-multi": ["-bad-specifier-", "foo"],
"./pattern/*.js": {
"default": ["-bad-specifier-", "./*.js"]
},
"./slash": ["/bar", "./a.js"],
"./no-slash": [".bar", "./a.js"],
"./utils/": {
"browser": "/a/",
"default": "/b/"
},
"./utils1/": "/a/",
"./utils2/": {
"default": "../this/"
},
"./utils3/*": {
"default": "../this/*"
},
"./utils4/*": "../src/*",
"./utils5/": "../src/",
"./*": ".",
"./valid/*.js": {
"default": ["-bad-specifier-", "./*.js"]
},
"./non-existent.js": ["-bad-specifier-", "./non-existent.js", "./a.js"],
"./bad-specifier.js": ["-bad-specifier-", "../../a.js", "./a.js"],
"./bad-specifier1.js": ["-bad-specifier-", "foo", "./a.js"],
"./dep/multi": ["../../test", "./a.js"],
"./dep/multi1": ["../../test", "../../test/foo"],
"./dep/multi2": ["../../test"],
"./dep/multi3": ["./a/../b/../../pack1/index.js", "./a.js"],
"./dep/multi4": [
"./a/../b/../../pack1/index.js",
"./c/../b/../../pack1/index.js"
],
"./dep/multi5": ["./a/../b/../../pack1/index.js"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "imports-field-chain",
"imports": {
"#a": "#b",
"#b": "./the.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "the";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@exports-field/bad-specifier",
"version": "1.0.0",
"imports": {
"/utils/": "./a/",
"/utils1/": {
"browser": "./a/",
"default": "./b/"
},
"a": "a.js",
"#": "a.js",
"#/dep": "a.js",
"#dep/": "a.js",
"#dep": [
"./a/../b/../../pack1/index.js",
"././-bad-specifier-",
"./a.js?foo=../"
],

"#dep/foo/*": [
"./a/../b/../../pack1/index.js",
"././-bad-specifier-",
"./a.js?foo=../#../"
],
"#dep/bar": "-bad-specifier-",
"#dep/baz": ["-bad-specifier-"],
"#dep/baz-multi": ["-bad-specifier-", "not-found"],
"#dep/pattern/*.js": {
"default": ["-bad-specifier-", "./*.js"]
},
"#dep/array": ["./a.js", "-bad-specifier-"],
"#dep/array2": ["-bad-specifier-", "./a.js"],
"#dep/array3": ["./a.js"],
"#dep/empty": "",
"#dep/with-bad": ["../foo", "./a.js"],
"#dep/with-bad2": ["./a.js", "../foo"],
"#timezones/": "./data/timezones",
"#dep/multi": ["../../test", "./a.js"],
"#dep/multi1": ["../../test", "../../test/foo"],
"#dep/multi2": ["../../test"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "imports-slash-pattern",
"imports": {
"#/*": "./src/*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "deep";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "utils";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function button() {
return "button";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const newFile = "new-file";
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as foo from "foo";
import * as file1 from "foo/file1";

import * as bar from "bar/file1";
import * as myStar from "star-bar";
import * as longest from "longest/bar";
import * as packagedBrowser from "browser-field-package";
import * as packagedMain from "main-field-package";
import * as packagedIndex from "no-main-field-package";
import * as newFile from "utils/old-file";

console.log(
"HELLO WORLD!",
foo.message,
bar.message,
file1,
longest,
myStar.message,
packagedBrowser.message,
packagedMain.message,
packagedIndex.message,
newFile
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "bar";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "HELLO!";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "browser";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "node";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "browser-field",
"main": "node.ts",
"browser": "browser.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "node";
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "main-field",
"main": "node.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "index";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "no-main-field"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "Hello Star!";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "HELLO WORLD!";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function date() {
return "date";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"outDir": "./js_out",
"baseUrl": ".",
"paths": {
"@components/*": [
"${configDir}/src/utils/*",
"${configDir}/src/components/*"
],
"@utils/*": ["./src/utils/*"],
"foo": ["${configDir}/src/mapped/foo"],
"foo/*": ["${configDir}/src/mapped/bar/*"],
"bar/*": ["./src/mapped/bar/*"],
"refs/*": ["${configDir}/src/refs/*"],
"*/old-file": ["${configDir}/src/components/new-file"],
"longest/*": [
"${configDir}/src/mapped/longest/four.ts",
"${configDir}/src/mapped/longest/two.ts"
],
"longest/bar": ["${configDir}/src/mapped/longest/three.ts"],
"*": ["${configDir}/src/mapped/star/*"]
},
"composite": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function button() {
return "button";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as button from "@components/button";
import * as date from "@utils/date";

console.log("HELLO WORLD!", button, date);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function date() {
return "date";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "${configDir}/../base/tsconfig",
"compilerOptions": {
"baseUrl": "."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = "foo";
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "${configDir}/../b/tsconfig",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@lib/*": ["${configDir}/src/lib/*"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const bar = "bar";
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "${configDir}/../a/tsconfig",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@util/*": ["${configDir}/src/util/*"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../lib/tsconfig"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tsconfig-base/tsconfig"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const format = (s: string) => s;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@base/*": ["./src/*"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function button() {
return "button";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as button from "@components/button";
import * as date from "@utils/date";

console.log("HELLO WORLD!", button, date);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function date() {
return "date";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["react/tsconfig"],
"compilerOptions": {
"baseUrl": "."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@my-tsconfig/base"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const Button = "button";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const bar = "bar";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = "foo";
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// This is a line comment
"compilerOptions": {
/* This is a block comment */
"baseUrl": ".",
"paths": {
// Another line comment
"@components/*": ["${configDir}/src/components/*"],
"foo": ["${configDir}/src/mapped/foo"],
/* Block comment in paths */
"bar/*": ["${configDir}/src/mapped/bar/*"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@components/*": ["components/*"],
// This is a comment which makes JSON invalid
"@utils/*": ["utils/*"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Button component
export const Button = "Button";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function appMain() {
return "app main";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@app/*": ["${configDir}/src/*"]
},
"composite": true,
"outDir": "./dist"
},
"references": [{ "path": "${configDir}/../shared" }]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { helper } from "utils/helper";
export { helper };
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Input component
export const Input = "Input";
Loading
Loading