├── fixtures ├── dot │ ├── foo.js │ └── foo │ │ ├── foo.js │ │ └── index.js ├── misc │ ├── 中文 │ │ └── 中文.js │ ├── module-type │ │ ├── file │ │ ├── cjs │ │ │ ├── file.cjs │ │ │ ├── file.js │ │ │ ├── file.mjs │ │ │ └── package.json │ │ ├── esm │ │ │ ├── file.cjs │ │ │ ├── file.js │ │ │ ├── file.mjs │ │ │ └── package.json │ │ ├── file.cjs │ │ ├── file.ext │ │ ├── file.json │ │ ├── file.mjs │ │ ├── file.node │ │ ├── file.wasm │ │ ├── no │ │ │ ├── file.js │ │ │ └── package.json │ │ └── package.json │ ├── dir-with-index │ │ └── index.js │ ├── package-json-with-bom │ │ ├── index.js │ │ └── package.json │ ├── node_modules │ │ └── package-json-nested │ │ │ ├── index.js │ │ │ ├── foo │ │ │ ├── bar │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ ├── index.js │ │ │ └── package.json │ │ │ └── package.json │ └── package.json ├── tsconfig │ ├── src │ │ └── foo.js │ ├── nested │ │ ├── index.js │ │ ├── test.js │ │ └── tsconfig.json │ ├── cases │ │ ├── empty │ │ │ ├── index.js │ │ │ └── tsconfig.json │ │ ├── field │ │ │ ├── index.js │ │ │ └── tsconfig.json │ │ ├── index │ │ │ ├── index.js │ │ │ └── tsconfig.json │ │ ├── suffixes │ │ │ ├── a.ts │ │ │ ├── b.ts │ │ │ ├── a.ios.ts │ │ │ ├── c-test.ts │ │ │ ├── index.ts │ │ │ └── tsconfig.json │ │ ├── base-url │ │ │ ├── index.ts │ │ │ ├── src │ │ │ │ └── foo.js │ │ │ └── tsconfig.json │ │ ├── builtins │ │ │ ├── thing.js │ │ │ └── tsconfig.json │ │ ├── exports │ │ │ ├── index.js │ │ │ └── tsconfig.json │ │ ├── with-bom │ │ │ ├── bar.js │ │ │ └── tsconfig.json │ │ ├── extends-extension │ │ │ ├── foo.js │ │ │ ├── tsconfig.json │ │ │ └── base-tsconfig.json │ │ ├── extends-multiple │ │ │ ├── foo.js │ │ │ └── tsconfig.json │ │ ├── trailing-comma │ │ │ ├── bar.js │ │ │ ├── index.js │ │ │ └── tsconfig.json │ │ ├── extends-extensionless │ │ │ ├── foo.js │ │ │ └── tsconfig.json │ │ ├── extends-not-found │ │ │ ├── index.js │ │ │ └── tsconfig.json │ │ ├── extends-paths │ │ │ ├── src │ │ │ │ └── index.js │ │ │ ├── tsconfig.base.json │ │ │ └── tsconfig.json │ │ ├── root-dirs-multiple │ │ │ ├── lib │ │ │ │ └── baz.ts │ │ │ ├── generated │ │ │ │ └── bar.ts │ │ │ ├── src │ │ │ │ └── index.ts │ │ │ └── tsconfig.json │ │ ├── root-dirs-nested │ │ │ ├── src │ │ │ │ ├── foo.ts │ │ │ │ └── sub │ │ │ │ │ ├── foo.ts │ │ │ │ │ └── index.ts │ │ │ └── tsconfig.json │ │ ├── root-dirs │ │ │ ├── generated │ │ │ │ └── foo.ts │ │ │ ├── src │ │ │ │ └── index.ts │ │ │ └── tsconfig.json │ │ ├── extends-paths-outside │ │ │ ├── src │ │ │ │ └── index.js │ │ │ └── tsconfig.json │ │ ├── paths-template-variable │ │ │ ├── src │ │ │ │ └── foo.js │ │ │ ├── tsconfig_extends1.json │ │ │ ├── tsconfig_extends2.json │ │ │ ├── tsconfig_extends3.json │ │ │ ├── tsconfig_extends4.json │ │ │ ├── tsconfig.json │ │ │ ├── tsconfig_base_url1.json │ │ │ └── tsconfig_base_url2.json │ │ ├── project-references │ │ │ ├── app │ │ │ │ ├── index.ts │ │ │ │ ├── aliased │ │ │ │ │ └── index.ts │ │ │ │ ├── tsconfig.nopaths.json │ │ │ │ └── tsconfig.json │ │ │ ├── project-a │ │ │ │ ├── index.ts │ │ │ │ ├── aliased │ │ │ │ │ └── index.ts │ │ │ │ └── conf.json │ │ │ ├── project-c │ │ │ │ ├── index.ts │ │ │ │ └── tsconfig.json │ │ │ ├── extends │ │ │ │ ├── src │ │ │ │ │ └── pages │ │ │ │ │ │ └── index.tsx │ │ │ │ ├── tsconfig.app.json │ │ │ │ ├── tsconfig.json │ │ │ │ └── tsconfig.base.json │ │ │ ├── project-b │ │ │ │ ├── src │ │ │ │ │ └── aliased │ │ │ │ │ │ └── index.ts │ │ │ │ └── tsconfig.json │ │ │ └── tsconfig.base.json │ │ ├── references-extend │ │ │ ├── src │ │ │ │ └── index.ts │ │ │ ├── tsconfig.a.json │ │ │ └── tsconfig.json │ │ ├── root-dirs-no-match │ │ │ ├── outside │ │ │ │ └── foo.ts │ │ │ ├── src │ │ │ │ └── index.ts │ │ │ └── tsconfig.json │ │ ├── root-dirs-single │ │ │ ├── src │ │ │ │ ├── foo.ts │ │ │ │ └── index.ts │ │ │ └── tsconfig.json │ │ ├── extends-paths-inheritance │ │ │ ├── src │ │ │ │ └── test.ts │ │ │ ├── tsconfig.json │ │ │ └── base-tsconfig.json │ │ ├── extends-template-vars │ │ │ ├── src │ │ │ │ └── utils.ts │ │ │ ├── tsconfig.json │ │ │ └── base-tsconfig.json │ │ ├── root-dirs-parent-nav │ │ │ ├── folder1 │ │ │ │ └── file1.ts │ │ │ ├── generated │ │ │ │ └── folder2 │ │ │ │ │ └── file3.ts │ │ │ └── tsconfig.json │ │ ├── parent-base-url │ │ │ ├── src │ │ │ │ └── index.ts │ │ │ ├── test │ │ │ │ └── story.ts │ │ │ ├── tsconfig.json │ │ │ └── tsconfigs │ │ │ │ ├── tsconfig.dev.json │ │ │ │ └── tsconfig.base.json │ │ ├── root-dirs-parent-dir │ │ │ ├── folder1 │ │ │ │ └── file1_1 │ │ │ │ │ └── index.ts │ │ │ ├── generated │ │ │ │ └── folder2 │ │ │ │ │ └── file3.ts │ │ │ └── tsconfig.json │ │ ├── root-dirs-trailing-slash │ │ │ ├── generated │ │ │ │ └── foo.ts │ │ │ ├── src │ │ │ │ └── index.ts │ │ │ └── tsconfig.json │ │ ├── absolute-alias │ │ │ ├── public │ │ │ │ └── images │ │ │ │ │ └── foo.ts │ │ │ ├── test.ts │ │ │ └── tsconfig.json │ │ ├── extends │ │ │ ├── tsconfig.json │ │ │ └── base-tsconfig.json │ │ ├── root-dirs-all-fail │ │ │ ├── src │ │ │ │ └── index.ts │ │ │ └── tsconfig.json │ │ ├── merge-compiler-options │ │ │ ├── tsconfig.json │ │ │ └── base-tsconfig.json │ │ ├── paths-nested-base │ │ │ ├── other │ │ │ │ └── bar.ts │ │ │ ├── root │ │ │ │ └── foo.ts │ │ │ └── tsconfig.json │ │ ├── extends-esm │ │ │ ├── tsconfig.json │ │ │ └── node_modules │ │ │ │ └── @org │ │ │ │ └── package │ │ │ │ ├── src │ │ │ │ └── tsconfig.json │ │ │ │ └── package.json │ │ ├── extends-main │ │ │ ├── tsconfig.json │ │ │ └── node_modules │ │ │ │ └── @org │ │ │ │ └── package │ │ │ │ ├── package.json │ │ │ │ └── src │ │ │ │ └── tsconfig.json │ │ ├── extends-chain │ │ │ ├── base-tsconfig.json │ │ │ ├── tsconfig.json │ │ │ └── intermediate-tsconfig.json │ │ ├── extends-preserve-child │ │ │ ├── base-tsconfig.json │ │ │ └── tsconfig.json │ │ ├── extends-override │ │ │ ├── base-tsconfig.json │ │ │ └── tsconfig.json │ │ └── no-merge-compiler-options │ │ │ ├── base-tsconfig.json │ │ │ └── tsconfig.json │ ├── tsconfig_broken.json │ ├── node_modules │ │ ├── tsconfig-field │ │ │ ├── foo.js │ │ │ ├── package.json │ │ │ └── conf.json │ │ ├── tsconfig-index │ │ │ ├── foo.js │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── tsconfig-exports │ │ │ ├── foo.js │ │ │ ├── conf.json │ │ │ └── package.json │ │ └── tsconfig-not-used │ │ │ ├── foo.js │ │ │ └── tsconfig.json │ ├── tsconfig.json │ ├── tsconfig_template_variable1.json │ ├── tsconfig_template_variable2.json │ ├── tsconfig_template_variable3.json │ ├── tsconfig_template_variable4.json │ └── package.json ├── tsconfck │ ├── find │ │ └── a │ │ │ ├── b │ │ │ ├── c │ │ │ │ ├── x.ts │ │ │ │ ├── y.js │ │ │ │ └── jsconfig.json │ │ │ ├── bar.ts │ │ │ └── qoox.js │ │ │ ├── jsconfig.json │ │ │ ├── tsconfig.json │ │ │ ├── .gitignore │ │ │ ├── node_modules │ │ │ ├── tsconfig.json │ │ │ ├── some-lib │ │ │ │ ├── src │ │ │ │ │ └── foo.ts │ │ │ │ └── tsconfig.json │ │ │ └── some-js-lib │ │ │ │ ├── src │ │ │ │ └── foo.js │ │ │ │ └── jsconfig.json │ │ │ ├── baz.js │ │ │ └── foo.ts │ ├── parse │ │ ├── valid │ │ │ ├── empty │ │ │ │ ├── jsconfig.json │ │ │ │ └── tsconfig.json │ │ │ ├── with-extends │ │ │ │ ├── dot │ │ │ │ │ ├── src │ │ │ │ │ │ └── foo.ts │ │ │ │ │ ├── tsconfig.eslint.json │ │ │ │ │ ├── tsconfig.json │ │ │ │ │ ├── main.js │ │ │ │ │ └── package.json │ │ │ │ ├── dotdot │ │ │ │ │ ├── src │ │ │ │ │ │ ├── foo.ts │ │ │ │ │ │ └── tsconfig.json │ │ │ │ │ ├── main.js │ │ │ │ │ ├── tsconfig.json │ │ │ │ │ └── package.json │ │ │ │ ├── nested │ │ │ │ │ ├── src │ │ │ │ │ │ ├── foo.ts │ │ │ │ │ │ ├── nested │ │ │ │ │ │ │ ├── bar.ts │ │ │ │ │ │ │ └── tsconfig.json │ │ │ │ │ │ └── tsconfig.json │ │ │ │ │ └── tsconfig.json │ │ │ │ ├── array │ │ │ │ │ ├── src │ │ │ │ │ │ └── foo.ts │ │ │ │ │ ├── tsconfig.c.json │ │ │ │ │ ├── tsconfig.json │ │ │ │ │ ├── tsconfig.b.json │ │ │ │ │ ├── tsconfig.a.b.json │ │ │ │ │ └── tsconfig.a.json │ │ │ │ ├── paths │ │ │ │ │ ├── lib │ │ │ │ │ │ └── foo.ts │ │ │ │ │ ├── src │ │ │ │ │ │ ├── import-foo.ts │ │ │ │ │ │ └── tsconfig.json │ │ │ │ │ └── tsconfig.base.json │ │ │ │ ├── no-compileroptions │ │ │ │ │ └── tsconfig.json │ │ │ │ ├── node-fallback │ │ │ │ │ └── tsconfig.json │ │ │ │ ├── node │ │ │ │ │ └── tsconfig.json │ │ │ │ ├── simple │ │ │ │ │ └── tsconfig.json │ │ │ │ ├── without-json-extension │ │ │ │ │ └── tsconfig.json │ │ │ │ └── tsconfig.parent.json │ │ │ ├── configDir │ │ │ │ ├── src │ │ │ │ │ └── foo.ts │ │ │ │ ├── a │ │ │ │ │ ├── src │ │ │ │ │ │ └── foo.ts │ │ │ │ │ └── tsconfig.json │ │ │ │ ├── b │ │ │ │ │ ├── src │ │ │ │ │ │ └── foo.ts │ │ │ │ │ └── tsconfig.json │ │ │ │ └── tsconfig.base.json │ │ │ ├── bom │ │ │ │ └── tsconfig.json │ │ │ ├── comma │ │ │ │ └── tsconfig.json │ │ │ ├── lib │ │ │ │ └── tsconfig.json │ │ │ ├── ts-node │ │ │ │ └── tsconfig.json │ │ │ ├── comments │ │ │ │ └── tsconfig.json │ │ │ ├── mixed │ │ │ │ └── tsconfig.json │ │ │ ├── configDirNpm │ │ │ │ └── tsconfig.json │ │ │ ├── regular │ │ │ │ └── tsconfig.json │ │ │ └── moduleResolution │ │ │ │ ├── bundler │ │ │ │ └── tsconfig.json │ │ │ │ ├── classic │ │ │ │ └── tsconfig.json │ │ │ │ ├── node16 │ │ │ │ └── tsconfig.json │ │ │ │ └── nodenext │ │ │ │ └── tsconfig.json │ │ ├── invalid │ │ │ ├── tsconfig.json │ │ │ │ └── .gitkeep │ │ │ ├── bom │ │ │ │ └── tsconfig.json │ │ │ ├── extends-array-circular │ │ │ │ ├── src │ │ │ │ │ └── foo.ts │ │ │ │ ├── tsconfig.c.json │ │ │ │ ├── tsconfig.json │ │ │ │ ├── tsconfig.b.json │ │ │ │ ├── tsconfig.a.b.json │ │ │ │ └── tsconfig.a.json │ │ │ ├── extends-circular │ │ │ │ ├── deep │ │ │ │ │ └── tsconfig.circular2.json │ │ │ │ ├── tsconfig.circular.json │ │ │ │ └── tsconfig.json │ │ │ ├── comma │ │ │ │ └── tsconfig.json │ │ │ ├── extends-not-found │ │ │ │ └── tsconfig.json │ │ │ ├── comments │ │ │ │ └── tsconfig.json │ │ │ └── mixed │ │ │ │ └── tsconfig.json │ │ └── solution │ │ │ ├── referenced-exclude │ │ │ ├── src │ │ │ │ ├── bar.ts │ │ │ │ └── foo.ts │ │ │ ├── tsconfig.bar.json │ │ │ ├── tsconfig.foo.json │ │ │ └── tsconfig.json │ │ │ ├── referenced-files │ │ │ ├── src │ │ │ │ ├── bar.ts │ │ │ │ └── foo.ts │ │ │ ├── tsconfig.foo.json │ │ │ └── tsconfig.json │ │ │ ├── referenced-include │ │ │ ├── src │ │ │ │ ├── bar.ts │ │ │ │ └── foo.ts │ │ │ ├── tsconfig.bar.json │ │ │ ├── tsconfig.foo.json │ │ │ └── tsconfig.json │ │ │ ├── mixed │ │ │ ├── src │ │ │ │ ├── bar.mts │ │ │ │ ├── foo.ts │ │ │ │ ├── baz.cts │ │ │ │ └── foo.spec.ts │ │ │ ├── tsconfig.base.json │ │ │ ├── tsconfig.test.json │ │ │ ├── tsconfig.json │ │ │ └── tsconfig.src.json │ │ │ ├── simple │ │ │ ├── src │ │ │ │ ├── foo.ts │ │ │ │ └── tsconfig.json │ │ │ ├── tests │ │ │ │ ├── tsconfig.json │ │ │ │ └── foo.ts │ │ │ ├── tsconfig.base.json │ │ │ └── tsconfig.json │ │ │ ├── jsconfig │ │ │ ├── src │ │ │ │ ├── bar.mjs │ │ │ │ ├── foo.js │ │ │ │ ├── baz.cjs │ │ │ │ └── foo.spec.js │ │ │ ├── jsconfig.test.json │ │ │ ├── jsconfig.json │ │ │ ├── jsconfig.src.json │ │ │ └── jsconfig.base.json │ │ │ ├── referenced-with-configDir │ │ │ ├── src │ │ │ │ └── foo.ts │ │ │ ├── tsconfig.json │ │ │ └── tsconfig.src.json │ │ │ ├── referenced-extends-original │ │ │ ├── src │ │ │ │ ├── foo.ts │ │ │ │ └── tsconfig.src.json │ │ │ ├── tsconfig.json │ │ │ └── tests │ │ │ │ ├── tsconfig.test.json │ │ │ │ └── foo.test.ts │ │ │ ├── referenced-with-implicit-globs │ │ │ ├── src │ │ │ │ └── foo.ts │ │ │ ├── tsconfig.src.json │ │ │ ├── tsconfig.test.json │ │ │ ├── tsconfig.json │ │ │ └── tests │ │ │ │ └── foo.test.ts │ │ │ └── referenced-with-configDir-and-extends │ │ │ ├── packages │ │ │ └── foo │ │ │ │ ├── src │ │ │ │ └── foo.ts │ │ │ │ └── tsconfig.foo.json │ │ │ ├── tsconfig.json │ │ │ └── tsconfig.base.json │ └── package.json ├── nested-symlink │ ├── nm │ │ └── index.js │ ├── apps │ │ ├── tooling │ │ └── web │ │ │ └── nm │ │ │ └── @repo │ │ │ ├── index.js │ │ │ └── typescript-config │ └── tooling │ │ └── typescript-config │ │ └── index.js ├── enhanced-resolve │ ├── test │ │ ├── fixtures │ │ │ ├── # │ │ │ │ └── a.js │ │ │ ├── lib.js │ │ │ ├── no.js │ │ │ ├── 测试.js │ │ │ ├── abc.txt │ │ │ ├── file.load1 │ │ │ ├── file.load2 │ │ │ ├── foo │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ ├── yield │ │ │ │ ├── a │ │ │ │ │ ├── foo │ │ │ │ │ │ ├── a │ │ │ │ │ │ └── b │ │ │ │ │ └── foo-2 │ │ │ │ │ │ ├── b │ │ │ │ │ │ └── c │ │ │ │ ├── b │ │ │ │ │ └── foo │ │ │ │ │ │ └── a │ │ │ │ └── c │ │ │ │ │ └── foo │ │ │ │ │ ├── a │ │ │ │ │ └── package.json │ │ │ ├── alias │ │ │ │ └── files │ │ │ │ │ └── a.js │ │ │ ├── crypto-js │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ ├── extensions │ │ │ │ ├── foo.js │ │ │ │ ├── foo.ts │ │ │ │ ├── bar.d.ts │ │ │ │ ├── dir │ │ │ │ │ ├── index.js │ │ │ │ │ └── index.ts │ │ │ │ ├── index.js │ │ │ │ ├── index.ts │ │ │ │ ├── app.module.js │ │ │ │ ├── node_modules │ │ │ │ │ ├── module.js │ │ │ │ │ └── module │ │ │ │ │ │ └── index.ts │ │ │ │ └── package.json │ │ │ ├── imports-field │ │ │ │ ├── b.js │ │ │ │ ├── dir │ │ │ │ │ └── b.js │ │ │ │ ├── node_modules │ │ │ │ │ ├── c │ │ │ │ │ │ └── index.js │ │ │ │ │ └── a │ │ │ │ │ │ ├── lib │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── browser.js │ │ │ │ │ │ ├── main.js │ │ │ │ │ │ └── lib2 │ │ │ │ │ │ │ └── main.js │ │ │ │ │ │ ├── x.js │ │ │ │ │ │ ├── main.js │ │ │ │ │ │ └── package.json │ │ │ │ ├── a.js │ │ │ │ └── package.json │ │ │ ├── no#fragment │ │ │ │ └── # │ │ │ │ │ └── #.js │ │ │ ├── pnp │ │ │ │ ├── pkg │ │ │ │ │ ├── index.js │ │ │ │ │ ├── main.js │ │ │ │ │ ├── dir │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── typescript │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── package-alias │ │ │ │ │ │ ├── browser.js │ │ │ │ │ │ └── index.js │ │ │ │ │ └── package.json │ │ │ │ └── pkg3 │ │ │ │ │ ├── a.js │ │ │ │ │ └── package.json │ │ │ ├── decorated-fs │ │ │ │ └── exists.js │ │ │ ├── shortcutdir.js │ │ │ │ └── a.js │ │ │ ├── browser-module │ │ │ │ ├── lib │ │ │ │ │ ├── ignore.js │ │ │ │ │ ├── main.js │ │ │ │ │ ├── self.js │ │ │ │ │ ├── browser.js │ │ │ │ │ ├── replaced.js │ │ │ │ │ └── toString.js │ │ │ │ ├── browser │ │ │ │ │ └── module-a.js │ │ │ │ ├── node_modules │ │ │ │ │ ├── module-a.js │ │ │ │ │ ├── module-b.js │ │ │ │ │ ├── module-c.js │ │ │ │ │ └── recursive-file │ │ │ │ │ │ ├── a.js │ │ │ │ │ │ ├── b.js │ │ │ │ │ │ ├── c.js │ │ │ │ │ │ ├── d.js │ │ │ │ │ │ └── package.json │ │ │ │ └── package.json │ │ │ ├── extension-alias │ │ │ │ ├── dir │ │ │ │ │ ├── index.js │ │ │ │ │ └── index.ts │ │ │ │ ├── index.js │ │ │ │ ├── index.mjs │ │ │ │ ├── index.mts.js │ │ │ │ ├── index.ts │ │ │ │ └── dir2 │ │ │ │ │ ├── index.js │ │ │ │ │ └── index.mts │ │ │ ├── incorrect-package │ │ │ │ ├── pack1 │ │ │ │ │ ├── a.js │ │ │ │ │ └── package.json │ │ │ │ └── pack2 │ │ │ │ │ ├── a.js │ │ │ │ │ └── package.json │ │ │ ├── issue-238 │ │ │ │ ├── src │ │ │ │ │ ├── a │ │ │ │ │ │ └── config.js │ │ │ │ │ └── common │ │ │ │ │ │ └── config │ │ │ │ │ │ └── myObjectFile.js │ │ │ │ └── package.json │ │ │ ├── main-field-self │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ ├── main-field-self2 │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ ├── node_modules │ │ │ │ ├── dash │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ │ ├── dash-name │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ │ ├── dir-and-file │ │ │ │ │ ├── foo.js │ │ │ │ │ ├── foo │ │ │ │ │ │ ├── bar.js │ │ │ │ │ │ └── index.js │ │ │ │ │ └── package.json │ │ │ │ ├── m1 │ │ │ │ │ ├── package.json │ │ │ │ │ ├── a.js │ │ │ │ │ └── b.js │ │ │ │ ├── m2 │ │ │ │ │ ├── package.json │ │ │ │ │ └── b.js │ │ │ │ ├── recursive-module │ │ │ │ │ ├── file.js │ │ │ │ │ └── index.js │ │ │ │ ├── @scope │ │ │ │ │ └── dir-and-file │ │ │ │ │ │ ├── foo.js │ │ │ │ │ │ ├── foo │ │ │ │ │ │ ├── bar.js │ │ │ │ │ │ └── index.js │ │ │ │ │ │ └── package.json │ │ │ │ ├── browser-module-broken │ │ │ │ │ ├── main.js │ │ │ │ │ ├── browser.js │ │ │ │ │ └── package.json │ │ │ │ ├── complexm │ │ │ │ │ ├── package.json │ │ │ │ │ ├── step2.js │ │ │ │ │ ├── node_modules │ │ │ │ │ │ └── m1 │ │ │ │ │ │ │ ├── a.js │ │ │ │ │ │ │ └── index.js │ │ │ │ │ └── step1.js │ │ │ │ └── invalidPackageJson │ │ │ │ │ └── package.json │ │ │ ├── roots-fall-through │ │ │ │ └── index.js │ │ │ ├── directory-default │ │ │ │ └── directory-default.js │ │ │ ├── prefer-pnp │ │ │ │ └── alternative-modules │ │ │ │ │ └── m1 │ │ │ │ │ └── b.js │ │ │ ├── dirOrFile.js │ │ │ ├── exports-field │ │ │ │ ├── a.js │ │ │ │ ├── node_modules │ │ │ │ │ ├── exports-field │ │ │ │ │ │ ├── lib │ │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ │ ├── main.js │ │ │ │ │ │ │ ├── browser.js │ │ │ │ │ │ │ └── lib2 │ │ │ │ │ │ │ │ └── main.js │ │ │ │ │ │ ├── main.js │ │ │ │ │ │ ├── x.js │ │ │ │ │ │ └── package.json │ │ │ │ │ └── invalid-exports-field │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── umd.js │ │ │ │ │ │ └── package.json │ │ │ │ └── package.json │ │ │ ├── restrictions │ │ │ │ └── node_modules │ │ │ │ │ ├── pck1 │ │ │ │ │ ├── index.css │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ │ │ └── pck2 │ │ │ │ │ ├── index.css │ │ │ │ │ ├── module.js │ │ │ │ │ └── package.json │ │ │ ├── scoped │ │ │ │ └── node_modules │ │ │ │ │ └── @scope │ │ │ │ │ ├── pack1 │ │ │ │ │ ├── main.js │ │ │ │ │ └── package.json │ │ │ │ │ └── pack2 │ │ │ │ │ ├── main.js │ │ │ │ │ ├── lib │ │ │ │ │ └── index.js │ │ │ │ │ └── package.json │ │ │ ├── dirOrFile │ │ │ │ └── index.js │ │ │ ├── exports-field-error │ │ │ │ └── node_modules │ │ │ │ │ ├── pack1 │ │ │ │ │ └── index.js │ │ │ │ │ └── exports-field │ │ │ │ │ └── package.json │ │ │ ├── exports-field3 │ │ │ │ └── node_modules │ │ │ │ │ └── exports-field │ │ │ │ │ ├── index │ │ │ │ │ ├── src │ │ │ │ │ └── index.js │ │ │ │ │ ├── main.js │ │ │ │ │ └── package.json │ │ │ ├── lib │ │ │ │ └── complex1.js │ │ │ ├── multiple-modules │ │ │ │ └── node_modules │ │ │ │ │ └── m1 │ │ │ │ │ ├── package.json │ │ │ │ │ └── a.js │ │ │ ├── imports-exports-wildcard │ │ │ │ └── node_modules │ │ │ │ │ └── m │ │ │ │ │ ├── src │ │ │ │ │ ├── features │ │ │ │ │ │ ├── f.js │ │ │ │ │ │ ├── y │ │ │ │ │ │ │ └── y.js │ │ │ │ │ │ └── internal │ │ │ │ │ │ │ └── file.js │ │ │ │ │ ├── internal │ │ │ │ │ │ └── i.js │ │ │ │ │ ├── middle-1 │ │ │ │ │ │ ├── f.js │ │ │ │ │ │ └── nested │ │ │ │ │ │ │ └── f.js │ │ │ │ │ ├── middle │ │ │ │ │ │ ├── f.js │ │ │ │ │ │ └── nested │ │ │ │ │ │ │ └── f.js │ │ │ │ │ ├── middle-4 │ │ │ │ │ │ └── f │ │ │ │ │ │ │ └── f.js │ │ │ │ │ ├── middle-5 │ │ │ │ │ │ ├── f$ │ │ │ │ │ │ │ └── $.js │ │ │ │ │ │ └── f │ │ │ │ │ │ │ └── $.js │ │ │ │ │ ├── middle-3 │ │ │ │ │ │ └── nested │ │ │ │ │ │ │ └── f │ │ │ │ │ │ │ └── nested │ │ │ │ │ │ │ └── f.js │ │ │ │ │ └── middle-2 │ │ │ │ │ │ └── nested │ │ │ │ │ │ └── f.js │ │ │ │ │ └── package.json │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ ├── exports-field2 │ │ │ │ └── node_modules │ │ │ │ │ └── exports-field │ │ │ │ │ ├── main.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── lib │ │ │ │ │ ├── main.js │ │ │ │ │ ├── browser.js │ │ │ │ │ └── lib2 │ │ │ │ │ │ └── main.js │ │ │ │ │ └── package.json │ │ │ ├── exports-field-and-extension-alias │ │ │ │ └── node_modules │ │ │ │ │ ├── pkg │ │ │ │ │ ├── dist │ │ │ │ │ │ ├── string.test.d.ts │ │ │ │ │ │ └── string.js │ │ │ │ │ └── package.json │ │ │ │ │ └── @org │ │ │ │ │ └── pkg │ │ │ │ │ ├── dist │ │ │ │ │ ├── string.test.d.ts │ │ │ │ │ └── string.js │ │ │ │ │ └── package.json │ │ │ ├── c.js │ │ │ ├── pnp-a │ │ │ │ └── m2 │ │ │ │ │ └── a.js │ │ │ ├── main3.js │ │ │ ├── main1.js │ │ │ ├── builtins │ │ │ │ └── package.json │ │ │ ├── main2.js │ │ │ └── complex.js │ │ └── .gitignore │ ├── lib │ │ └── index.js │ └── package.json ├── pnp │ ├── .yarnrc.yml │ ├── tsconfig.json │ ├── shared │ │ ├── lib.js │ │ └── tsconfig.base.json │ ├── .gitignore │ ├── index.test.mjs │ └── package.json ├── prefer-file-over-dir │ ├── node_modules │ │ ├── bar.js │ │ ├── @foo │ │ │ ├── bar.js │ │ │ └── bar │ │ │ │ └── index.js │ │ └── bar │ │ │ ├── index.js │ │ │ └── package.json │ ├── .gitignore │ └── package.json ├── abnormal-relative-with-node_modules │ ├── runner.js │ ├── node_modules │ │ └── .gitkeep │ ├── foo │ │ └── bar │ │ │ └── baz │ │ │ ├── test.mjs │ │ │ └── test.js │ └── package.json ├── abnormal-relative-without-node_modules │ ├── runner.js │ ├── foo │ │ └── bar │ │ │ └── baz │ │ │ ├── test.mjs │ │ │ └── test.js │ └── package.json ├── yarn │ ├── .gitignore │ ├── .yarnrc.yml │ ├── package.json │ └── yarn.lock ├── global-pnp │ ├── .yarnrc.yml │ ├── test.js │ ├── .gitignore │ ├── package.json │ └── yarn.lock ├── pnpm-workspace │ ├── .gitignore │ ├── packages │ │ ├── app │ │ │ └── package.json │ │ └── lib │ │ │ └── package.json │ └── package.json ├── invalid │ └── node_modules │ │ ├── a │ │ ├── dist │ │ │ └── index.js │ │ └── package.json │ │ └── main_field_fallback │ │ ├── exist.js │ │ └── package.json └── pnpm │ ├── longfilename │ ├── index.js │ └── package.json │ └── package.json ├── .node-version ├── CLAUDE.md ├── tests ├── tsconfig.json ├── tsconfig_self_reference.json ├── package.json ├── tsconfig_circular_reference_a.json └── tsconfig_circular_reference_b.json ├── napi ├── .gitignore ├── build.rs ├── browser.js ├── tests │ ├── utils.mjs │ ├── simple.test.mjs │ └── options.test.mjs ├── patch.mjs ├── src │ └── tracing.rs ├── webcontainer-fallback.js ├── test.mjs ├── wasi-worker-browser.mjs ├── wasi-worker.mjs ├── Cargo.toml └── resolver.wasi-browser.js ├── .clippy.toml ├── fuzz ├── .gitignore ├── fuzz_targets │ └── resolver.rs └── Cargo.toml ├── rust-toolchain.toml ├── .typos.toml ├── .gitignore ├── .github ├── SECURITY.md ├── codecov.yml ├── renovate.json ├── workflows │ ├── deny.yml │ ├── zizmor.yml │ ├── benchmark.yml │ ├── autofix.yml │ ├── copilot-setup-steps.yml │ ├── release.yml │ └── codecov.yml └── actions │ └── pnpm │ └── action.yml ├── .editorconfig ├── CONTRIBUTING.md ├── pnpm-workspace.yaml ├── .cargo └── config.toml ├── src ├── cache │ ├── thread_local.rs │ ├── hasher.rs │ ├── borrowed_path.rs │ └── mod.rs ├── tests │ ├── resolution.rs │ ├── tsconfig_discovery.rs │ ├── module_type.rs │ ├── main_field.rs │ ├── clear_cache.rs │ ├── scoped_packages.rs │ ├── mod.rs │ └── incorrect_description_file.rs ├── builtins.rs ├── package_json │ └── mod.rs └── context.rs ├── .rustfmt.toml ├── dprint.json ├── LICENSE ├── examples ├── file.rs └── many.rs └── package.json /fixtures/dot/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/dot/foo/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/中文/中文.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | 22.17.0 2 | -------------------------------------------------------------------------------- /CLAUDE.md: -------------------------------------------------------------------------------- 1 | @AGENTS.md 2 | -------------------------------------------------------------------------------- /fixtures/dot/foo/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/src/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/file: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/b/c/x.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/b/c/y.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/nested/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/nested/test.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | } 3 | -------------------------------------------------------------------------------- /fixtures/misc/dir-with-index/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/cjs/file.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/cjs/file.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/cjs/file.mjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/esm/file.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/esm/file.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/esm/file.mjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/file.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/file.ext: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/file.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/file.mjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/file.node: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/file.wasm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/no/file.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/nested-symlink/nm/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/empty/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/field/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/index/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/suffixes/a.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/suffixes/b.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /napi/.gitignore: -------------------------------------------------------------------------------- 1 | *.node 2 | *.wasm 3 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/base-url/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/base-url/src/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/builtins/thing.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/empty/tsconfig.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/exports/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/suffixes/a.ios.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/suffixes/c-test.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/with-bom/bar.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/#/a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/lib.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/no.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/测试.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/no/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/misc/package-json-with-bom/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/nested-symlink/apps/tooling: -------------------------------------------------------------------------------- 1 | ../tooling -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/jsconfig.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/tsconfig.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-extension/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-multiple/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/trailing-comma/bar.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/trailing-comma/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/tsconfig_broken.json: -------------------------------------------------------------------------------- 1 | { 2 | -------------------------------------------------------------------------------- /.clippy.toml: -------------------------------------------------------------------------------- 1 | avoid-breaking-exported-api = false 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/abc.txt: -------------------------------------------------------------------------------- 1 | abc -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/file.load1: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/file.load2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/foo/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/yield/a/foo/a: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/yield/a/foo/b: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/yield/b/foo/a: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/yield/c/foo/a: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/nested-symlink/apps/web/nm/@repo/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/pnp/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | enableGlobalCache: false 2 | -------------------------------------------------------------------------------- /fixtures/prefer-file-over-dir/node_modules/bar.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/.gitignore: -------------------------------------------------------------------------------- 1 | !node_modules 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/b/c/jsconfig.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/node_modules/tsconfig.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/empty/jsconfig.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/empty/tsconfig.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-extensionless/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-not-found/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-paths/src/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-multiple/lib/baz.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-nested/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs/generated/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-field/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-index/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-with-node_modules/runner.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-without-node_modules/runner.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/alias/files/a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/crypto-js/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/b.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/no#fragment/#/#.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg/main.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/yield/a/foo-2/b: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/yield/a/foo-2/c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/node_modules/package-json-nested/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/prefer-file-over-dir/.gitignore: -------------------------------------------------------------------------------- 1 | !node_modules 2 | -------------------------------------------------------------------------------- /fixtures/prefer-file-over-dir/node_modules/@foo/bar.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/prefer-file-over-dir/node_modules/bar/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/node_modules/some-lib/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/tsconfig.json/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dot/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-paths-outside/src/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-template-variable/src/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/app/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/references-extend/src/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-nested/src/sub/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-no-match/outside/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-exports/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-not-used/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/yarn/.gitignore: -------------------------------------------------------------------------------- 1 | .yarn/* 2 | !.yarn/releases 3 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/decorated-fs/exists.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/bar.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/dir/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/dir/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/dir/b.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg/dir/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/shortcutdir.js/a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/global-pnp/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | enableGlobalCache: true 2 | -------------------------------------------------------------------------------- /fixtures/misc/node_modules/package-json-nested/foo/bar/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/node_modules/package-json-nested/foo/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "misc" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/prefer-file-over-dir/node_modules/@foo/bar/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/b/bar.ts: -------------------------------------------------------------------------------- 1 | export const bar = 'bar'; 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/baz.js: -------------------------------------------------------------------------------- 1 | export const baz = 'baz'; 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/foo.ts: -------------------------------------------------------------------------------- 1 | export const foo = 'foo'; 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/node_modules/some-js-lib/src/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-exclude/src/bar.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-exclude/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-files/src/bar.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-files/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-include/src/bar.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-include/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dotdot/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/nested/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/app/aliased/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/project-a/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/project-c/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-multiple/generated/bar.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/suffixes/index.ts: -------------------------------------------------------------------------------- 1 | import './a'; 2 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-with-node_modules/node_modules/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/lib/ignore.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/lib/main.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/lib/self.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extension-alias/dir/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extension-alias/dir/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extension-alias/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extension-alias/index.mjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extension-alias/index.mts.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extension-alias/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/app.module.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/incorrect-package/pack1/a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/incorrect-package/pack2/a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/issue-238/src/a/config.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/main-field-self/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/main-field-self2/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/dash/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg/typescript/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/roots-fall-through/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/pnpm-workspace/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/b/qoox.js: -------------------------------------------------------------------------------- 1 | export const qoox = "qoox"; 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/node_modules/some-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/nested/src/nested/bar.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-single/src/foo.ts: -------------------------------------------------------------------------------- 1 | export {} 2 | -------------------------------------------------------------------------------- /fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | corpus 3 | artifacts 4 | coverage 5 | -------------------------------------------------------------------------------- /napi/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | napi_build::setup(); 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/lib/browser.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/lib/replaced.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/lib/toString.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extension-alias/dir2/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extension-alias/dir2/index.mts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/node_modules/module.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/dash-name/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/dir-and-file/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg/package-alias/browser.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg/package-alias/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfck/find/a/node_modules/some-js-lib/jsconfig.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-paths-inheritance/src/test.ts: -------------------------------------------------------------------------------- 1 | // test file -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-template-vars/src/utils.ts: -------------------------------------------------------------------------------- 1 | // utils file -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/extends/src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/project-a/aliased/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/project-b/src/aliased/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs/src/index.ts: -------------------------------------------------------------------------------- 1 | import {} from './foo' 2 | -------------------------------------------------------------------------------- /napi/browser.js: -------------------------------------------------------------------------------- 1 | export * from '@oxc-resolver/binding-wasm32-wasi' 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/browser/module-a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/directory-default/directory-default.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/node_modules/c/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/incorrect-package/pack2/package.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/dir-and-file/foo/bar.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/dir-and-file/foo/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/m1/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/m2/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/recursive-module/file.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/recursive-module/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg3/a.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/prefer-pnp/alternative-modules/m1/b.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/esm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "commonjs" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/nested-symlink/tooling/typescript-config/index.js: -------------------------------------------------------------------------------- 1 | ../../nm/index.js -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-parent-nav/folder1/file1.ts: -------------------------------------------------------------------------------- 1 | export {} 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/node_modules/module-a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/node_modules/module-b.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/node_modules/module-c.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/dirOrFile.js: -------------------------------------------------------------------------------- 1 | module.exports = "file"; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/a.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/node_modules/module/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/a.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/node_modules/a/lib/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/issue-238/src/common/config/myObjectFile.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/@scope/dir-and-file/foo.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/@scope/dir-and-file/foo/bar.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/browser-module-broken/main.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/complexm/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/restrictions/node_modules/pck1/index.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/restrictions/node_modules/pck1/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/restrictions/node_modules/pck2/index.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/restrictions/node_modules/pck2/module.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/scoped/node_modules/@scope/pack1/main.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/scoped/node_modules/@scope/pack2/main.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/global-pnp/test.js: -------------------------------------------------------------------------------- 1 | console.log(require.resolve('source-map-support')) 2 | -------------------------------------------------------------------------------- /fixtures/misc/module-type/cjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "commonjs" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/pnp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "lib/tsconfig.base.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/bom/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": x"" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-include/tsconfig.bar.json: -------------------------------------------------------------------------------- 1 | { 2 | } 3 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/parent-base-url/src/index.ts: -------------------------------------------------------------------------------- 1 | export const foo = 'bar' 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/parent-base-url/test/story.ts: -------------------------------------------------------------------------------- 1 | export * from "index"; 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-parent-dir/folder1/file1_1/index.ts: -------------------------------------------------------------------------------- 1 | export {} 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-single/src/index.ts: -------------------------------------------------------------------------------- 1 | import {} from './foo' 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-trailing-slash/generated/foo.ts: -------------------------------------------------------------------------------- 1 | export {} 2 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.92.0" 3 | profile = "default" 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/node_modules/recursive-file/a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/node_modules/recursive-file/b.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/node_modules/recursive-file/c.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/node_modules/recursive-file/d.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/dirOrFile/index.js: -------------------------------------------------------------------------------- 1 | module.exports = "dir"; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field-error/node_modules/pack1/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field3/node_modules/exports-field/index: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/@scope/dir-and-file/foo/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/browser-module-broken/browser.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/invalidPackageJson/package.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/scoped/node_modules/@scope/pack2/lib/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/invalid/node_modules/a/dist/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | hello: 42 3 | } -------------------------------------------------------------------------------- /fixtures/pnp/shared/lib.js: -------------------------------------------------------------------------------- 1 | module.exports = function(){ 2 | return 42; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-nested/src/sub/index.ts: -------------------------------------------------------------------------------- 1 | import {} from './foo' 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-trailing-slash/src/index.ts: -------------------------------------------------------------------------------- 1 | import {} from './foo' 2 | -------------------------------------------------------------------------------- /napi/tests/utils.mjs: -------------------------------------------------------------------------------- 1 | export const normalizePath = (p) => p.replaceAll('\\', '/'); 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/exports-field/lib/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/lib/complex1.js: -------------------------------------------------------------------------------- 1 | module.exports = "lib complex1"; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/multiple-modules/node_modules/m1/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/prefer-file-over-dir/node_modules/bar/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bar" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/prefer-file-over-dir/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prefer-file-over-dir" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/array/src/foo.ts: -------------------------------------------------------------------------------- 1 | export const foo = 'foo'; 2 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/paths/lib/foo.ts: -------------------------------------------------------------------------------- 1 | export const foo = 'foo'; 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/absolute-alias/public/images/foo.ts: -------------------------------------------------------------------------------- 1 | export default 'image.webp' 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/exports/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tsconfig-exports" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig.json" 3 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/field/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tsconfig-field" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/index/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tsconfig-index" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-all-fail/src/index.ts: -------------------------------------------------------------------------------- 1 | import {} from './nonexistent' 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-no-match/src/index.ts: -------------------------------------------------------------------------------- 1 | import {} from '../outside/foo' 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/lib/index.js: -------------------------------------------------------------------------------- 1 | // mimic enhanced-resolved root directory structure 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/invalid-exports-field/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/invalid-exports-field/umd.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field3/node_modules/exports-field/src/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/features/f.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/internal/i.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle-1/f.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle/f.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/node_modules/a/x.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/issue-238/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/m2/b.js: -------------------------------------------------------------------------------- 1 | module.exports = "This is m2/b"; 2 | -------------------------------------------------------------------------------- /fixtures/invalid/node_modules/main_field_fallback/exist.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | foo: 42 3 | } -------------------------------------------------------------------------------- /fixtures/misc/node_modules/package-json-nested/foo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/nested-symlink/apps/web/nm/@repo/typescript-config: -------------------------------------------------------------------------------- 1 | ../../../../tooling/typescript-config -------------------------------------------------------------------------------- /fixtures/pnpm/longfilename/index.js: -------------------------------------------------------------------------------- 1 | const test = 'hello world' 2 | 3 | export default test 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-array-circular/src/foo.ts: -------------------------------------------------------------------------------- 1 | export const foo = 'foo'; 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-not-found/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./not-found" 3 | } 4 | -------------------------------------------------------------------------------- /tests/tsconfig_self_reference.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig_self_reference.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/extensions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "./index.js" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/features/y/y.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle-4/f/f.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle-5/f$/$.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle-5/f/$.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle/nested/f.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/node_modules/a/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/main-field-self/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "./" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/main-field-self2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "." 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/complexm/step2.js: -------------------------------------------------------------------------------- 1 | module.exports = "Step2"; 2 | -------------------------------------------------------------------------------- /fixtures/misc/node_modules/package-json-nested/foo/bar/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bar" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/mixed/src/bar.mts: -------------------------------------------------------------------------------- 1 | export function bar() { 2 | return 'bar'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/mixed/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/simple/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/configDir/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dot/tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "." 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dot/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src/**/*"] 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dotdot/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ".." 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/yarn/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | 3 | yarnPath: .yarn/releases/yarn-4.9.2.cjs 4 | -------------------------------------------------------------------------------- /tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "name", 3 | "type": "module", 4 | "sideEffects": {} 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle-1/nested/f.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/node_modules/a/lib/browser.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/node_modules/a/lib/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/incorrect-package/pack1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "./a.js", 3 | -------------------------------------------------------------------------------- /fixtures/misc/node_modules/package-json-nested/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "package-json-nested" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/jsconfig/src/bar.mjs: -------------------------------------------------------------------------------- 1 | export function bar() { 2 | return 'bar'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/jsconfig/src/foo.js: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/configDir/a/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/configDir/a/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["../tsconfig.base.json"] 3 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/configDir/b/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/configDir/b/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["../tsconfig.base.json"] 3 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-template-vars/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig.json" 3 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/merge-compiler-options/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /tests/tsconfig_circular_reference_a.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig_circular_reference_b.json" 3 | } 4 | -------------------------------------------------------------------------------- /tests/tsconfig_circular_reference_b.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig_circular_reference_a.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "enhanced-resolve", 3 | "main": "lib/index.js" 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/a.js: -------------------------------------------------------------------------------- 1 | module.exports = function a() { 2 | return "This is a"; 3 | }; 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/b.js: -------------------------------------------------------------------------------- 1 | module.exports = function b() { 2 | return "This is b"; 3 | }; 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/exports-field/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/exports-field/x.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field2/node_modules/exports-field/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field3/node_modules/exports-field/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/features/internal/file.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle-3/nested/f/nested/f.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/node_modules/a/lib/lib2/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/pnp/shared/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-exclude/tsconfig.bar.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude": ["src/foo.ts"] 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-exclude/tsconfig.foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude": ["src/bar.ts"] 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-files/tsconfig.foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["src/foo.ts"] 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-include/tsconfig.foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src/foo.ts"] 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/absolute-alias/test.ts: -------------------------------------------------------------------------------- 1 | import image from '/images/foo.js' 2 | 3 | console.log(image) 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-extensionless/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tsconfig-field/conf" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-paths-inheritance/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig.json" 3 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-paths-outside/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/parent-base-url/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfigs/tsconfig.dev" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-multiple/src/index.ts: -------------------------------------------------------------------------------- 1 | import {} from './bar' 2 | import {} from './baz' 3 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-parent-dir/generated/folder2/file3.ts: -------------------------------------------------------------------------------- 1 | import {} from '../folder1/file1_1' 2 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-parent-nav/generated/folder2/file3.ts: -------------------------------------------------------------------------------- 1 | import {} from '../folder1/file1' 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/exports-field/lib/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field2/node_modules/exports-field/index.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field2/node_modules/exports-field/lib/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/foo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo", 3 | "version": "1.0.0" 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/nested/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/builtins/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "." 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/parent-base-url/tsconfigs/tsconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-nested-base/other/bar.ts: -------------------------------------------------------------------------------- 1 | // import using tsconfig.json `baseUrl` 2 | import 'foo' 3 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/exports-field/lib/browser.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/exports-field/lib/lib2/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field2/node_modules/exports-field/lib/browser.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field2/node_modules/exports-field/lib/lib2/main.js: -------------------------------------------------------------------------------- 1 | module.exports = 1; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/complexm/node_modules/m1/a.js: -------------------------------------------------------------------------------- 1 | module.exports = "the correct a.js"; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/dir-and-file/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dir-and-file" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/restrictions/node_modules/pck1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "index.js" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/scoped/node_modules/@scope/pack2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "./main.js" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/mixed/src/baz.cts: -------------------------------------------------------------------------------- 1 | function baz() { 2 | return 'baz'; 3 | } 4 | module.exports = {baz} 5 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-configDir/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dot/main.js: -------------------------------------------------------------------------------- 1 | export default function(){ 2 | return 'not a tsconfig' 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dotdot/main.js: -------------------------------------------------------------------------------- 1 | export default function(){ 2 | return 'not a tsconfig' 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/base-url/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./src" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-nested-base/root/foo.ts: -------------------------------------------------------------------------------- 1 | // import using tsconfig.json path mapping 2 | import 'other/bar' 3 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/extends/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-index/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tsconfig-index", 3 | "private": true 4 | } -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field-and-extension-alias/node_modules/pkg/dist/string.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/complexm/step1.js: -------------------------------------------------------------------------------- 1 | module.exports = require("m1/a") + require("m1"); 2 | -------------------------------------------------------------------------------- /fixtures/invalid/node_modules/a/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "a", 3 | "main": "/dist/index.js", 4 | "version": "1.0.0" 5 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-circular/deep/tsconfig.circular2.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/jsconfig/src/baz.cjs: -------------------------------------------------------------------------------- 1 | function baz() { 2 | return 'baz'; 3 | } 4 | module.exports = {baz} 5 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-extends-original/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-implicit-globs/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/bom/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strictNullChecks": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/comma/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["foo", ] , 4 | } , 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-esm/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@org/package"], 3 | "compilerOptions": { 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/c.js: -------------------------------------------------------------------------------- 1 | module.exports = function b() { 2 | require("./a"); 3 | return "This is c"; 4 | }; 5 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field-and-extension-alias/node_modules/@org/pkg/dist/string.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/@scope/dir-and-file/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@scope/dir-and-file" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/m1/a.js: -------------------------------------------------------------------------------- 1 | module.exports = function a() { 2 | return "This is m1/a"; 3 | }; 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/m1/b.js: -------------------------------------------------------------------------------- 1 | module.exports = function a() { 2 | return "This is m1/b"; 3 | }; 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp-a/m2/a.js: -------------------------------------------------------------------------------- 1 | module.exports = function a() { 2 | return "This is nested m1/a"; 3 | }; 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-circular/tsconfig.circular.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./deep/tsconfig.circular2.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-main/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@org/package"], 3 | "compilerOptions": { 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-no-match/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": ["./src"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-single/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": ["./src"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-with-node_modules/foo/bar/baz/test.mjs: -------------------------------------------------------------------------------- 1 | console.log(import.meta.resolve('jest-runner-../../..')) // error 2 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-without-node_modules/foo/bar/baz/test.mjs: -------------------------------------------------------------------------------- 1 | console.log(import.meta.resolve('jest-runner-../../..')) // error 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field-and-extension-alias/node_modules/pkg/dist/string.js: -------------------------------------------------------------------------------- 1 | export default "string"; 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/complexm/node_modules/m1/index.js: -------------------------------------------------------------------------------- 1 | module.exports = " :) " + require("m2/b.js"); 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/dash/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dash", 3 | "exports": "./index.js" 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/paths/src/import-foo.ts: -------------------------------------------------------------------------------- 1 | import foo from '$lib/foo'; 2 | export const foobar = foo + 'bar;'; 3 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/references-extend/tsconfig.a.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["**/*.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/.gitignore: -------------------------------------------------------------------------------- 1 | # created by symlink.rs 2 | /temp.* 3 | 4 | # Currently not used. 5 | /temp 6 | /temp_symlinks 7 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field-and-extension-alias/node_modules/@org/pkg/dist/string.js: -------------------------------------------------------------------------------- 1 | export default "string"; 2 | -------------------------------------------------------------------------------- /fixtures/pnp/.gitignore: -------------------------------------------------------------------------------- 1 | .pnp.* 2 | .yarn/* 3 | !.yarn/patches 4 | !.yarn/plugins 5 | !.yarn/releases 6 | !.yarn/sdks 7 | !.yarn/versions 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/parent-base-url/tsconfigs/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "../src" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-template-variable/tsconfig_extends1.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig_template_variable1.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-template-variable/tsconfig_extends2.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig_template_variable2.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-template-variable/tsconfig_extends3.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig_template_variable3.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-template-variable/tsconfig_extends4.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig_template_variable4.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/project-c/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": ["./src", "./generated"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/suffixes/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleSuffixes": [".ios", "-test", ""] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "ts-path": ["src/foo.js"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/src/middle-2/nested/f.js: -------------------------------------------------------------------------------- 1 | module.exports = { nested: "nested" } 2 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/dash-name/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dash-name", 3 | "exports": "./index.js" 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/global-pnp/.gitignore: -------------------------------------------------------------------------------- 1 | .pnp.* 2 | .yarn/* 3 | !.yarn/patches 4 | !.yarn/plugins 5 | !.yarn/releases 6 | !.yarn/sdks 7 | !.yarn/versions 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-configDir-and-extends/packages/foo/src/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | return 'foo'; 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/array/tsconfig.c.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strictNullChecks": true, 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/array/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["./tsconfig.a.json","./tsconfig.b.json","./tsconfig.c.json"] 3 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-all-fail/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": ["./src", "./generated"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-nested/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": ["./src", "./src/sub"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-parent-dir/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": [".", "./generated"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-parent-nav/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": [".", "./generated"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/main3.js: -------------------------------------------------------------------------------- 1 | var a = require("./a"); 2 | require.ensure([], function(require) { 3 | require("./c.js"); 4 | }); 5 | -------------------------------------------------------------------------------- /fixtures/tsconfck/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@tsconfig/node18": "^18.2.4", 4 | "isaacscript-tsconfig": "^7.0.1" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/comma/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "", 3 | "compilerOptions": { 4 | "types": ["foo", ] , 5 | } , x 6 | } 7 | 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-array-circular/tsconfig.c.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strictNullChecks": true, 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dotdot/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.parent.json", 3 | "include": ["src/**/*"] 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/nested/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.parent.json", 3 | "include": ["src/**/*"] 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-main/node_modules/@org/package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@org/package", 3 | "main": "src/tsconfig.json" 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/with-bom/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "foo": ["bar.js"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-field/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tsconfig-field", 3 | "private": true, 4 | "tsconfig": "conf.json" 5 | } -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/multiple-modules/node_modules/m1/a.js: -------------------------------------------------------------------------------- 1 | module.exports = function a() { 2 | return "This is nested m1/a"; 3 | }; 4 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/node_modules/browser-module-broken/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "./main.js", 3 | "browser": "./browser.js" 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/scoped/node_modules/@scope/pack1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "browser": { 3 | "./index.js": "./main.js" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-array-circular/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["./tsconfig.a.json","./tsconfig.b.json","./tsconfig.c.json"] 3 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-configDir-and-extends/packages/foo/tsconfig.foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-esm/node_modules/@org/package/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-main/node_modules/@org/package/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-paths/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "@/*": ["./*"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-multiple/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": ["./src", "./generated", "./lib"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/root-dirs-trailing-slash/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDirs": ["./src/", "./generated"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.typos.toml: -------------------------------------------------------------------------------- 1 | # https://github.com/crate-ci/typos 2 | # cargo install typos-cli 3 | # typos 4 | 5 | [files] 6 | extend-exclude = [ 7 | "CHANGELOG.md", 8 | ] 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/absolute-alias/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "/*": ["./public/*"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-chain/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true, 4 | "target": "ES5" 5 | } 6 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-preserve-child/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react-jsx", 4 | "target": "ES2020" 5 | } 6 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-exports/conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "foo": ["foo.js"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-field/conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "foo": ["foo.js"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-index/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "foo": ["foo.js"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@exports-field/core", 3 | "version": "1.0.0", 4 | "exports": "./a.js" 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/mixed/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "strictNullChecks": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-files/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [{ 4 | "path": "./tsconfig.foo.json" 5 | }] 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/simple/tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base", 3 | "compilerOptions": { 4 | "strict": false 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/simple/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "strictNullChecks": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": [ 4 | "ES2020", 5 | "ES2021.Promise" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-extension/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "foo": ["foo.js"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-paths/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": { 4 | "baseUrl": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/yield/c/foo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo", 3 | "version": "1.0.0", 4 | "browser": { 5 | "./a": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/invalid/node_modules/main_field_fallback/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "main_field_fallback", 3 | "main": "./exist.js", 4 | "module": "./non-exist.js" 5 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-configDir/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [{ 4 | "path": "./tsconfig.src.json" 5 | }] 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/no-compileroptions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.parent.json", 3 | "include": ["src/**/*", "foo.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-chain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./intermediate-tsconfig.json", 3 | "compilerOptions": { 4 | "module": "ESNext" 5 | } 6 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-preserve-child/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig.json", 3 | "compilerOptions": { 4 | "jsx": "preserve" 5 | } 6 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/nested/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "..", 3 | "compilerOptions": { 4 | "paths": { 5 | "ts-path": ["test.js"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-not-used/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "ts-path": ["foo.js"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/tsconfig_template_variable1.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "foo": ["${configDir}/src/foo.js"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-with-node_modules/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "abnormal-relative-with-node_modules", 3 | "version": "0.1.0", 4 | "main": "runner.js" 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/crypto-js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "crypto-js", 3 | "main": "index.js", 4 | "browser": { 5 | "crypto": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-chain/intermediate-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2022" 5 | } 6 | } -------------------------------------------------------------------------------- /fixtures/yarn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "extension-alias", 3 | "packageManager": "yarn@4.9.2", 4 | "devDependencies": { 5 | "typescript": "^5.8.3" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-without-node_modules/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "abnormal-relative-without-node_modules", 3 | "version": "0.1.0", 4 | "main": "runner.js" 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/restrictions/node_modules/pck2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "../../../c.js", 3 | "module": "module.js", 4 | "style": "index.css" 5 | } 6 | -------------------------------------------------------------------------------- /fixtures/global-pnp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "global-pnp", 3 | "packageManager": "yarn@4.9.2", 4 | "dependencies": { 5 | "source-map-support": "^0.5.21" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-override/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react-jsx", 4 | "target": "ES5", 5 | "module": "CommonJS" 6 | } 7 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/node_modules/tsconfig-exports/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tsconfig-exports", 3 | "private": true, 4 | "exports": { 5 | ".": "./conf.json" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/pnpm-workspace/packages/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@monorepo/app", 3 | "private": true, 4 | "dependencies": { 5 | "@monorepo/lib": "workspace:*" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-override/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig.json", 3 | "compilerOptions": { 4 | "jsx": "react", 5 | "target": "ES2020" 6 | } 7 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/extends/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { 5 | "path": "./tsconfig.app.json" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | /npm 3 | /node_modules 4 | /napi/node_modules 5 | /fixtures/pnpm/node_modules 6 | /fixtures/yarn/node_modules 7 | /fixtures/tsconfck/node_modules 8 | fuzz/Cargo.lock 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/simple/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "include": [], 4 | "references": [ 5 | {"path": "./src"}, 6 | {"path": "./tests"} 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/nested/src/nested/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "strictNullChecks": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-multiple/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["../extends-extension", "../extends-paths"], 3 | "compilerOptions": { 4 | "baseUrl": ".", 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-paths-inheritance/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./src", 4 | "paths": { 5 | "@/*": ["*"] 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-configDir-and-extends/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [{ 4 | "path": "./packages/foo/tsconfig.foo.json" 5 | }] 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/simple/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["./foo.ts"], 3 | "extends": "../tsconfig.base", 4 | "compilerOptions": { 5 | "strict": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-template-vars/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "${configDir}/src", 4 | "paths": { 5 | "@/*": ["*"] 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/project-a/conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "paths": { 5 | "@/*": ["./aliased/*"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/tsconfig_template_variable2.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "${configDir}", 4 | "paths": { 5 | "foo": ["./src/foo.js"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/tsconfig_template_variable3.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "foo": ["${configDir}/src/foo.js"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/mixed/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base", 3 | "include": ["src/**/*.spec.ts"], 4 | "compilerOptions": { 5 | "strict": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/array/tsconfig.b.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.a.b.json", 3 | "compilerOptions": { 4 | "noImplicitAny": true 5 | }, 6 | "files": ["src/**"] 7 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/jsconfig/jsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./jsconfig.base", 3 | "include": ["src/**/*.spec.js"], 4 | "compilerOptions": { 5 | "strict": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-extends-original/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "references": [ 3 | {"path": "./src/tsconfig.src.json"}, 4 | {"path": "./tests/tsconfig.test.json"} 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-implicit-globs/tsconfig.src.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src"], 3 | "compilerOptions": { 4 | "composite": true, 5 | "strict": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-implicit-globs/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["tests"], 3 | "compilerOptions": { 4 | "composite": true, 5 | "strict": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/paths/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base", 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "strictNullChecks": true 6 | } 7 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/tsconfig_template_variable4.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "${configDir}", 4 | "paths": { 5 | "foo": ["${configDir}/src/foo.js"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@exports-field/core", 3 | "version": "1.0.0", 4 | "exports": { 5 | ".": "./a.js", 6 | "./x": "./a.js" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-array-circular/tsconfig.b.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.a.b.json", 3 | "compilerOptions": { 4 | "noImplicitAny": true 5 | }, 6 | "files": ["src/**"] 7 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-template-variable/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "paths": { 5 | "foo": ["${configDir}/src/foo.js"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-template-variable/tsconfig_base_url1.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "${configDir}", 4 | "paths": { 5 | "@/*": ["./src/*"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-template-variable/tsconfig_base_url2.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "${configDir}/", 4 | "paths": { 5 | "@/*": ["./src/*"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/misc/package-json-with-bom/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@oxc-resolver/test-package-json-with-bom", 3 | "private": true, 4 | "version": "0.0.0", 5 | "main": "index.js", 6 | "type": "module" 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/mixed/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "include": [], 4 | "references": [ 5 | {"path": "./tsconfig.src.json"}, 6 | {"path": "./tsconfig.test.json"} 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-exclude/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [{ 4 | "path": "./tsconfig.foo.json" 5 | }, { 6 | "path": "./tsconfig.bar.json" 7 | }] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-include/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [{ 4 | "path": "./tsconfig.foo.json" 5 | }, { 6 | "path": "./tsconfig.bar.json" 7 | }] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/jsconfig/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "include": [], 4 | "references": [ 5 | {"path": "./jsconfig.src.json"}, 6 | {"path": "./jsconfig.test.json"} 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-implicit-globs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | {"path": "./tsconfig.src.json"}, 5 | {"path": "./tsconfig.test.json"} 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/trailing-comma/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | /* some comment */ 5 | "foo": ["bar.js"], 6 | }, 7 | }, 8 | // another comment 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/node_modules/recursive-file/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "browser": { 3 | "a.js": "./a", 4 | "./b.js": "./b", 5 | "c.js": "./d.js", 6 | "./d.js": "./c.js" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/pnp/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "main.js", 3 | "browser": { 4 | "./package-alias/index.js": "./package-alias/browser.js", 5 | "module": "pkg/dir/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dummy", 3 | "private": true, 4 | "version": "0.0.0", 5 | "//": "main field is found by createRequire", 6 | "main": "main.js" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/mixed/tsconfig.src.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base", 3 | "include": ["src/**/*"], 4 | "exclude": ["src/**/*.spec.ts"], 5 | "compilerOptions": { 6 | "strict": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/dotdot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dummy", 3 | "private": true, 4 | "version": "0.0.0", 5 | "//": "main field is found by createRequire", 6 | "main": "main.js" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | ## Reporting a Vulnerability 6 | 7 | If you find any potential vulnerability, join our [discord channel](https://discord.gg/9uXCAwqQZW) and contact Boshen. 8 | -------------------------------------------------------------------------------- /fixtures/pnpm-workspace/packages/lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@monorepo/lib", 3 | "version": "0.0.1", 4 | "private": true, 5 | "type": "module", 6 | "dependencies": { 7 | "react": "^19.1.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/jsconfig/jsconfig.src.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./jsconfig.base", 3 | "include": ["src/**/*"], 4 | "exclude": ["src/**/*.spec.js"], 5 | "compilerOptions": { 6 | "strict": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field-error/node_modules/exports-field/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exports-field", 3 | "version": "1.0.0", 4 | "exports": { 5 | ".": "./a/../b/../../pack1/index.js" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/main1.js: -------------------------------------------------------------------------------- 1 | var a = require("./a"); 2 | if (x) { 3 | for (var i = 0; i < 100; i++) { 4 | while (true) require("./b"); 5 | do { 6 | i++; 7 | } while (require("m1/a")()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-extends-original/src/tsconfig.src.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["./foo.ts"], 3 | "extends": "../tsconfig", 4 | "compilerOptions": { 5 | "composite": true, 6 | "strict": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/project-b/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "baseUrl": "./src", 5 | "paths": { 6 | "@/*": ["./aliased/*"] 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | indent_style=space 5 | indent_size=2 6 | tab_width=2 7 | end_of_line=lf 8 | charset=utf-8 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.rs] 13 | indent_size = 4 14 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-circular/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.circular.json", 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "strictNullChecks": true 6 | }, 7 | "include": ["src/**/*"] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/node-fallback/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node18", 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "strictNullChecks": true 6 | }, 7 | "include": ["src/**/*"] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/references-extend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "files": [], 4 | "include": [], 5 | "references": [ 6 | { 7 | "path": "./tsconfig.a.json" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-with-node_modules/foo/bar/baz/test.js: -------------------------------------------------------------------------------- 1 | console.log(require.resolve('jest-runner-../../..')) 2 | 3 | console.log(require.resolve('jest-runner-/../..')) 4 | 5 | console.log(require.resolve('jest-runner-../..')) // error 6 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-array-circular/tsconfig.a.b.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["./tsconfig.a.json"], // extending a here introduces a loop because a extends a.b too 3 | "compilerOptions": { 4 | "disableSizeLimit": true 5 | } 6 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-array-circular/tsconfig.a.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.a.b.json", 3 | "compilerOptions": { 4 | "strictNullChecks": false, 5 | "noImplicitAny": false 6 | }, 7 | "files": ["src/foo.ts"] 8 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/extends-not-found/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.doesnotexist.json", 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "strictNullChecks": true 6 | }, 7 | "include": ["src/**/*"] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/jsconfig/jsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, //must be true so that js extensions are globbed correctly 4 | "composite": true, 5 | "strictNullChecks": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-extends-original/tests/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["./*.test.ts"], 3 | "extends": "../tsconfig", 4 | "compilerOptions": { 5 | "composite": true, 6 | "strict": false 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/node/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node18/tsconfig.json", 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "strictNullChecks": true 6 | }, 7 | "include": ["src/**/*"] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/paths-nested-base/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "root/", 4 | "paths": { 5 | "other/*": ["../other/*"] 6 | } 7 | }, 8 | "files": ["root/foo.ts", "other/bar.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/simple/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.parent.json", 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "strictNullChecks": true 6 | }, 7 | "include": ["src/**/*", "foo.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/extends/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react-jsx", 4 | "paths": { 5 | "@/*": ["${configDir}/src/*"] 6 | } 7 | }, 8 | "include": ["${configDir}/src"] 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/without-json-extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.parent", 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "strictNullChecks": true 6 | }, 7 | "include": ["src/**/*", "foo.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /fixtures/abnormal-relative-without-node_modules/foo/bar/baz/test.js: -------------------------------------------------------------------------------- 1 | console.log(require.resolve('jest-runner-../../..')) // error 2 | 3 | console.log(require.resolve('jest-runner-/../..')) // error 4 | 5 | console.log(require.resolve('jest-runner-../..')) // error 6 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/builtins/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "builtins", 3 | "private": true, 4 | "imports": { 5 | "#fs": { 6 | "default": "fs" 7 | }, 8 | "#http": { 9 | "node": "node:http" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/ts-node/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noLib": false 4 | }, 5 | "ts-node": { 6 | "preferTsExts": true, 7 | "compilerOptions": { 8 | "noLib": true 9 | } 10 | }, 11 | "something": "bla" 12 | } -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field3/node_modules/exports-field/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exports-field", 3 | "exportsField": { 4 | "exports": "./main.js" 5 | }, 6 | "ex": "./index", 7 | "broken": { 8 | ".": "./src" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/mixed/src/foo.spec.ts: -------------------------------------------------------------------------------- 1 | import { foo } from './foo.js'; 2 | import * as assert from 'assert'; 3 | 4 | function test() { 5 | const actual = foo(); 6 | const expected = 'foo'; 7 | assert.strictEqual(actual, expected); 8 | } 9 | test(); 10 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/simple/tests/foo.ts: -------------------------------------------------------------------------------- 1 | import { foo } from '../src/foo'; 2 | import * as assert from 'assert'; 3 | 4 | function test() { 5 | const actual = foo(); 6 | const expected = 'foo'; 7 | assert.strictEqual(actual, expected); 8 | } 9 | test(); 10 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field-and-extension-alias/node_modules/@org/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@org/pkg", 3 | "exports": { 4 | "./*.js": { 5 | "types": "./dist/*.d.ts", 6 | "default": "./dist/*.js" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field-and-extension-alias/node_modules/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@raviqqe/hidash", 3 | "exports": { 4 | "./*.js": { 5 | "types": "./dist/*.d.ts", 6 | "default": "./dist/*.js" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/jsconfig/src/foo.spec.js: -------------------------------------------------------------------------------- 1 | import { foo } from './foo.js'; 2 | import * as assert from 'assert'; 3 | 4 | function test() { 5 | const actual = foo(); 6 | const expected = 'foo'; 7 | assert.strictEqual(actual, expected); 8 | } 9 | test(); 10 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/no-merge-compiler-options/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": false, 4 | "jsx": "aaa", 5 | "jsxFactory": "bbb", 6 | "jsxFragmentFactory": "ccc", 7 | "jsxImportSource": "ddd" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends-esm/node_modules/@org/package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@org/package", 3 | "exports": { 4 | ".": { 5 | "types": "./src/tsconfig.json", 6 | "import": "./src/tsconfig.json", 7 | "require": "./src/tsconfig.json" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.github/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: 5 | informational: true 6 | patch: 7 | default: 8 | informational: true 9 | changes: 10 | default: 11 | informational: true 12 | 13 | ignore: 14 | - "examples" 15 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING.md 2 | 3 | ```bash 4 | just init 5 | just install 6 | just ready 7 | ``` 8 | 9 | ## Rust 10 | 11 | ```bash 12 | just example /path/to/directory specifier 13 | just test 14 | ``` 15 | 16 | ## Napi 17 | 18 | ```bash 19 | pnpm run build 20 | pnpm test 21 | ``` 22 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/main2.js: -------------------------------------------------------------------------------- 1 | var a = require("./a"); 2 | with (x) { 3 | switch (a) { 4 | case 1: 5 | require("./b"); 6 | default: 7 | require.ensure(["m1/a"], function() { 8 | var a = require("m1/a"), 9 | b = require("m1/b"); 10 | }); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-extends-original/tests/foo.test.ts: -------------------------------------------------------------------------------- 1 | import { foo } from '../src/foo'; 2 | import * as assert from 'assert'; 3 | 4 | function test() { 5 | const actual = foo(); 6 | const expected = 'foo'; 7 | assert.strictEqual(actual, expected); 8 | } 9 | test(); 10 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-implicit-globs/tests/foo.test.ts: -------------------------------------------------------------------------------- 1 | import { foo } from '../src/foo'; 2 | import * as assert from 'assert'; 3 | 4 | function test() { 5 | const actual = foo(); 6 | const expected = 'foo'; 7 | assert.strictEqual(actual, expected); 8 | } 9 | test(); 10 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/array/tsconfig.a.b.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["./tsconfig.c.json"], // extending c here works because it does not create a loop 3 | "compilerOptions": { 4 | "disableSizeLimit": true // this hasn't been defined before, so it is expected in the output 5 | } 6 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/array/tsconfig.a.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.a.b.json", 3 | "compilerOptions": { 4 | "strictNullChecks": false, 5 | "noImplicitAny": false 6 | }, 7 | "files": ["src/foo.ts"] // files is not extended so expected output still has src/** (b extends a) 8 | } -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/paths/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.parent.json", 3 | "compilerOptions": { 4 | "baseUrl": ".", 5 | "paths": { 6 | "$lib": ["*","./lib"], 7 | "$src": ["./src"] 8 | } 9 | }, 10 | "include": ["src/**/*","lib/**/*"] 11 | } -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/no-merge-compiler-options/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./base-tsconfig", 3 | "compilerOptions": { 4 | "experimentalDecorators": true, 5 | "jsx": "react-jsx", 6 | "jsxFactory": "h", 7 | "jsxFragmentFactory": "Fragment", 8 | "jsxImportSource": "xxx" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fixtures/pnpm-workspace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "monorepo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "keywords": [], 7 | "author": "", 8 | "license": "MIT", 9 | "dependencies": { 10 | "enhanced-resolve": "^5.18.2", 11 | "oxc-resolver": "workspace:*" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-configDir/tsconfig.src.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ES2022", 4 | "moduleResolution": "bundler", 5 | "noUnusedLocals": true, 6 | "skipLibCheck": true, 7 | "experimentalDecorators": true, 8 | }, 9 | "include": ["${configDir}/src/*"] 10 | } 11 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - npm 3 | - napi 4 | - fixtures/pnpm 5 | - fixtures/tsconfck 6 | - fixtures/pnpm-workspace/** 7 | 8 | ignoredBuiltDependencies: 9 | - esbuild 10 | 11 | ignoreScripts: true 12 | 13 | # For `windows_symlinked_longfilename` in tests/resolve_test.rs 14 | virtualStoreDirMaxLength: 1024 15 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/merge-compiler-options/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true, 4 | "jsx": "react-jsx", 5 | "jsxFactory": "h", 6 | "jsxFragmentFactory": "Fragment", 7 | "jsxImportSource": "xxx", 8 | "module": "ESNext", 9 | "target": "ESNext" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/solution/referenced-with-configDir-and-extends/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ES2022", 4 | "moduleResolution": "bundler", 5 | "noUnusedLocals": true, 6 | "skipLibCheck": true, 7 | "experimentalDecorators": true, 8 | }, 9 | "include": ["${configDir}/src/*"] 10 | } 11 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/comments/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* 2 | multi 3 | line 4 | */ 5 | { 6 | "compilerOptions": { //trailing-single-line-comment 7 | "types": /* inline comment */ [ 8 | "//keep \"this", 9 | "/*", 10 | // extra line single comment 11 | "*/", 12 | "/* this too */" 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/configDir/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["${configDir}/**/*"], 3 | "exclude": ["${configDir}/src/**/*.spec.ts"], 4 | "compilerOptions": { 5 | "paths": { 6 | "$src": ["${configDir}/src/**/*"] 7 | }, 8 | "baseUrl": "${configDir}/src", 9 | "outDir": "${configDir}/build" 10 | } 11 | } -------------------------------------------------------------------------------- /fixtures/pnpm/longfilename/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@oxc-resolver/test-longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 | "private": true, 4 | "version": "0.0.0", 5 | "main": "index.js", 6 | "type": "module" 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/comments/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* 2 | multi 3 | line 4 | */ 5 | { 6 | "extends": "", // trailing single line comment 7 | "compilerOptions": { 8 | "types": /* inline comment */ [ 9 | "//keep this", 10 | "/*", 11 | // extra line single comment 12 | "*/", 13 | "/* this too */" 14 | ] x 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/invalid-exports-field/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exports-field", 3 | "version": "1.0.0", 4 | "main": "./main.js", 5 | "browser": { 6 | "./lib/main.js": "./lib/browser.js", 7 | "./dist/main.js": "./lib/browser.js" 8 | }, 9 | "exports": { 10 | ".": "./index.js", 11 | "umd": "./umd.js" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/mixed/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* 2 | multi 3 | line 4 | */ 5 | { 6 | "compilerOptions": { // trailing single line comment 7 | "types": /* inline comment */ [ 8 | "//keep this", 9 | "/*", 10 | // extra line single comment 11 | "*/", 12 | "/* this too */" , //<-dangling 13 | ] /* dangling->*/, 14 | // still dangling ^ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | # Addresses a potential segmentation fault issue that occurs when 2 | # running napi-rs within a Node.js worker thread on GNU/Linux systems. 3 | # See https://x.com/Brooooook_lyn/status/1895848334692401270 4 | [target.'cfg(target_env = "gnu")'] 5 | rustflags = ["-C", "link-args=-Wl,-z,nodelete"] 6 | 7 | [target.wasm32-wasip1-threads] 8 | rustflags = ["-Clink-args=-zstack-size=64000000 --max-memory=4294967296"] 9 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/invalid/mixed/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* 2 | multi 3 | line 4 | */ 5 | { 6 | "extends": "", // trailing single line comment 7 | "compilerOptions": { 8 | "types": /* inline comment */ [ 9 | "//keep this", 10 | "/*", 11 | // extra line single comment 12 | "*/", 13 | "/* this too */" , //<-dangling 14 | ] /* dangling->*/, 15 | // still dangling ^ 16 | } x 17 | } 18 | -------------------------------------------------------------------------------- /src/cache/thread_local.rs: -------------------------------------------------------------------------------- 1 | use std::{cell::RefCell, path::PathBuf}; 2 | 3 | thread_local! { 4 | /// Per-thread pre-allocated path that is used to perform operations on paths more quickly. 5 | /// Learned from parcel 6 | pub static SCRATCH_PATH: RefCell = RefCell::new(PathBuf::with_capacity(256)); 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/configDirNpm/tsconfig.json: -------------------------------------------------------------------------------- 1 | // The configuration file for TypeScript. 2 | { 3 | "$schema": "https://raw.githubusercontent.com/complete-ts/complete/main/packages/complete-tsconfig/schemas/tsconfig-strict-schema.json", 4 | 5 | "extends": [ 6 | // https://github.com/IsaacScript/isaacscript/blob/main/packages/isaacscript-tsconfig/tsconfig.mod.json 7 | "isaacscript-tsconfig/tsconfig.mod.json", 8 | ], 9 | } 10 | -------------------------------------------------------------------------------- /fuzz/fuzz_targets/resolver.rs: -------------------------------------------------------------------------------- 1 | #![no_main] 2 | 3 | use libfuzzer_sys::fuzz_target; 4 | use oxc_resolver::Resolver; 5 | 6 | fuzz_target!(|data: &[u8]| { 7 | if let Ok(s) = std::str::from_utf8(data) { 8 | if s.chars().all(|s| !s.is_control()) { 9 | let resolver = Resolver::default(); 10 | let cwd = std::env::current_dir().unwrap(); 11 | let _ = resolver.resolve(cwd, &s); 12 | } 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/regular/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["foo.ts"], 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "importsNotUsedAsValues": "error", 6 | "module": "es2020", 7 | "moduleResolution": "node", 8 | "newLine": "lf", 9 | "target": "esnext" 10 | }, 11 | "watchOptions": { 12 | "watchFile": "useFsEvents", 13 | "watchDirectory": "useFsEvents", 14 | "fallbackPolling": "dynamicPriority" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "imports-field", 3 | "version": "1.0.0", 4 | "exports": "./a.js", 5 | "imports": { 6 | "#imports-field": "./b.js", 7 | "#b": "../b.js", 8 | "#ccc/": "c/", 9 | "#c": "c", 10 | "#a/": "a/", 11 | "#query": "./a.js?query", 12 | "#fragment": "./a.js#fragment" 13 | }, 14 | "other": { 15 | "imports": { 16 | "#b": "./a.js" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/pnp/index.test.mjs: -------------------------------------------------------------------------------- 1 | import { test } from 'node:test' 2 | import assert from 'node:assert' 3 | import pnpapi from 'pnpapi' 4 | 5 | import { ResolverFactory } from '../../napi/index.js' 6 | 7 | test('resolver', () => { 8 | const resolver = new ResolverFactory() 9 | const directory = import.meta.dirname 10 | const resolution = resolver.sync(directory, 'is-even') 11 | assert.strictEqual(resolution.path, pnpapi.resolveRequest('is-even', directory)) 12 | }) 13 | -------------------------------------------------------------------------------- /fuzz/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "resolver_fuzz" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | # Use independent workspace for fuzzers 8 | [workspace] 9 | members = ["."] 10 | 11 | [package.metadata] 12 | cargo-fuzz = true 13 | 14 | [[bin]] 15 | name = "resolver" 16 | path = "fuzz_targets/resolver.rs" 17 | test = false 18 | doc = false 19 | bench = false 20 | 21 | [dependencies] 22 | libfuzzer-sys = "0.4.7" 23 | oxc_resolver = { path = ".." } 24 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/moduleResolution/bundler/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["foo.ts"], 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "importsNotUsedAsValues": "error", 6 | "module": "node16", 7 | "moduleResolution": "bundler", 8 | "newLine": "lf", 9 | "target": "esnext" 10 | }, 11 | "watchOptions": { 12 | "watchFile": "useFsEvents", 13 | "watchDirectory": "useFsEvents", 14 | "fallbackPolling": "dynamicPriority" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/moduleResolution/classic/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["foo.ts"], 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "importsNotUsedAsValues": "error", 6 | "module": "node16", 7 | "moduleResolution": "classic", 8 | "newLine": "lf", 9 | "target": "esnext" 10 | }, 11 | "watchOptions": { 12 | "watchFile": "useFsEvents", 13 | "watchDirectory": "useFsEvents", 14 | "fallbackPolling": "dynamicPriority" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/moduleResolution/node16/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["foo.ts"], 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "importsNotUsedAsValues": "error", 6 | "module": "node16", 7 | "moduleResolution": "node16", 8 | "newLine": "lf", 9 | "target": "esnext" 10 | }, 11 | "watchOptions": { 12 | "watchFile": "useFsEvents", 13 | "watchDirectory": "useFsEvents", 14 | "fallbackPolling": "dynamicPriority" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/app/tsconfig.nopaths.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "baseUrl": "./" 5 | }, 6 | "references": [ 7 | { 8 | "path": "../project-a/conf.json" 9 | }, 10 | { 11 | "path": "../project-b" 12 | }, 13 | { 14 | "path": "../project-c/tsconfig.json" 15 | }, 16 | { 17 | "path": "../../paths-template-variable/tsconfig.json" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["github>Boshen/renovate"], 4 | "ignorePaths": ["**/node_modules/**", "**/fixtures/**"], 5 | "packageRules": [ 6 | { 7 | "groupName": "pnp", 8 | "matchManagers": ["cargo"], 9 | "matchPackageNames": ["pnp"], 10 | "rangeStrategy": "auto", 11 | "schedule": ["at any time"], 12 | "automergeSchedule": ["at any time"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/moduleResolution/nodenext/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["foo.ts"], 3 | "compilerOptions": { 4 | "types": ["foo"], 5 | "importsNotUsedAsValues": "error", 6 | "module": "nodenext", 7 | "moduleResolution": "nodenext", 8 | "newLine": "lf", 9 | "target": "esnext" 10 | }, 11 | "watchOptions": { 12 | "watchFile": "useFsEvents", 13 | "watchDirectory": "useFsEvents", 14 | "fallbackPolling": "dynamicPriority" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/complex.js: -------------------------------------------------------------------------------- 1 | var complex1 = require("./lib/complex1"); 2 | require.ensure(["./lib/complex1", "complexm/step2"], function(require) { 3 | require("./lib/complex1"); 4 | var a = function() {}; 5 | require.ensure(["complexm/step1"], function(require) { 6 | require("./lib/complex1"); 7 | var s1 = require("complexm/step1"); 8 | var s2 = require("complexm/step2"); 9 | console.log(s1); 10 | console.log(s2); 11 | }); 12 | }); 13 | console.log(complex1); 14 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field2/node_modules/exports-field/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exports-field", 3 | "version": "1.0.0", 4 | "main": "./main.js", 5 | "browser": { 6 | "./lib/main.js": "./lib/browser.js", 7 | "./dist/main.js": "./lib/browser.js" 8 | }, 9 | "exports": { 10 | ".": "./index.js", 11 | "./dist/": { 12 | "webpack": ["./lib/lib2/", "./lib/"], 13 | "node": "./lib/", 14 | "default": "./lib/" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-field/node_modules/a/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "a", 3 | "version": "1.0.0", 4 | "main": "./main.js", 5 | "browser": { 6 | "./lib/main.js": "./lib/browser.js", 7 | "./dist/main.js": "./lib/browser.js" 8 | }, 9 | "exports": { 10 | ".": "./x.js", 11 | "./dist/": { 12 | "webpack": ["./lib/lib2/", "./lib/"], 13 | "node": "./lib/", 14 | "default": "./lib/" 15 | }, 16 | "./dist/a.js": "./../../a.js" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/cache/hasher.rs: -------------------------------------------------------------------------------- 1 | use std::hash::Hasher; 2 | 3 | /// Since the cache key is memoized, use an identity hasher 4 | /// to avoid double cache. 5 | #[derive(Default)] 6 | pub struct IdentityHasher(u64); 7 | 8 | impl Hasher for IdentityHasher { 9 | fn write(&mut self, _: &[u8]) { 10 | unreachable!("Invalid use of IdentityHasher") 11 | } 12 | 13 | fn write_u64(&mut self, n: u64) { 14 | self.0 = n; 15 | } 16 | 17 | fn finish(&self) -> u64 { 18 | self.0 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/extends/base-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./src", 4 | "allowJs": true, 5 | "emitDecoratorMetadata": true, 6 | "useDefineForClassFields": true, 7 | "rewriteRelativeImportExtensions": true, 8 | "jsx": "react-jsx", 9 | "jsxFactory": "React.createElement", 10 | "jsxFragmentFactory": "React.Fragment", 11 | "jsxImportSource": "react" 12 | }, 13 | "files": ["files"], 14 | "include": ["include"], 15 | "exclude": ["exclude"] 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/tsconfck/parse/valid/with-extends/tsconfig.parent.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["bar"], 4 | "strictNullChecks": false, 5 | "noImplicitAny": true 6 | }, 7 | "watchOptions": { 8 | "watchFile": "useFsEvents", 9 | "watchDirectory": "useFsEvents", 10 | "fallbackPolling": "dynamicPriority" 11 | }, 12 | "exclude": ["**/foo/*"], 13 | // the following keys should not be inherited by extending 14 | "something": "bla", 15 | "ts-node": { 16 | "skipIgnore": true 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /fixtures/tsconfig/cases/project-references/app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "paths": { 6 | "@/*": ["./aliased/*"] 7 | } 8 | }, 9 | "references": [ 10 | { 11 | "path": "../project-a/conf.json" 12 | }, 13 | { 14 | "path": "../project-b" 15 | }, 16 | { 17 | "path": "../project-c/tsconfig.json" 18 | }, 19 | { 20 | "path": "../../paths-template-variable/tsconfig.json" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | style_edition = "2024" 2 | 3 | # Make Rust more readable given most people have wide screens nowadays. 4 | # This is also the setting used by [rustc](https://github.com/rust-lang/rust/blob/master/rustfmt.toml) 5 | use_small_heuristics = "Max" 6 | 7 | # Use field initialize shorthand if possible 8 | use_field_init_shorthand = true 9 | 10 | reorder_modules = true 11 | 12 | # For `cargo +nightly fmt` 13 | # unstable_features = true 14 | # style_edition = '2024' 15 | # reorder_impl_items = true 16 | # group_imports = "StdExternalCrate" 17 | # imports_granularity = "Crate" 18 | -------------------------------------------------------------------------------- /fixtures/tsconfig/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resolver", 3 | "private": true, 4 | "alias": { 5 | "aliased": "foo", 6 | "aliased-file": "./bar.js", 7 | "something": "./nested/test.js", 8 | "aliasedfolder": "./nested", 9 | "aliasedabsolute": "/nested", 10 | "foo/bar": "./bar.js", 11 | "glob/*/*": "./nested/$2", 12 | "./baz": "./bar.js", 13 | "url": false 14 | }, 15 | "imports": { 16 | "#test": "./bar.js" 17 | }, 18 | "dependencies": { 19 | "foo": "^0.3.4" 20 | }, 21 | "peerDependencies": { 22 | "bar": "*" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /fixtures/pnpm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pnpm", 3 | "version": "1.0.0", 4 | "private": true, 5 | "devDependencies": { 6 | "@oxc-resolver/test-longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": "file:longfilename", 7 | "axios": "1.8.4", 8 | "decimal.js": "10.5.0", 9 | "ipaddr.js": "2.2.0", 10 | "mathjs": "14.4.0", 11 | "minimatch": "10.0.1", 12 | "postcss": "8.5.3", 13 | "styled-components": "6.1.17" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /napi/patch.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | 3 | const filename = './napi/index.js'; 4 | let data = fs.readFileSync(filename, 'utf-8'); 5 | data = data.replace( 6 | '\nif (!nativeBinding) {', 7 | (s) => 8 | ` 9 | if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) { 10 | try { 11 | nativeBinding = require('./webcontainer-fallback.js'); 12 | } catch (err) { 13 | loadErrors.push(err) 14 | } 15 | } 16 | ` + s, 17 | ); 18 | data = data + ` 19 | if (process.versions.pnp) { 20 | process.env.OXC_RESOLVER_YARN_PNP = '1' 21 | } 22 | ` 23 | fs.writeFileSync(filename, data); 24 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/exports-field/node_modules/exports-field/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exports-field", 3 | "version": "1.0.0", 4 | "main": "./main.js", 5 | "browser": { 6 | "./lib/main.js": "./lib/browser.js", 7 | "./dist/main.js": "./lib/browser.js" 8 | }, 9 | "exports": { 10 | ".": "./x.js", 11 | "./dist/": { 12 | "webpack": ["./lib/lib2/", "./lib/"], 13 | "node": "./lib/", 14 | "default": "./lib/" 15 | }, 16 | "./dist/a.js": "./../../a.js", 17 | "./query.js": "./x.js?query", 18 | "./fragment.js": "./x.js#fragment" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /fixtures/pnp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pnp", 3 | "packageManager": "yarn@4.9.2", 4 | "scripts": { 5 | "test": "yarn node index.test.mjs" 6 | }, 7 | "dependencies": { 8 | "@atlaskit/pragmatic-drag-and-drop": "^1.5.2", 9 | "@custom/pragmatic-drag-and-drop": "npm:@atlaskit/pragmatic-drag-and-drop@^1.5.2", 10 | "beachball": "^2.52.0", 11 | "custom-minimist": "npm:minimist@^1.2.8", 12 | "is-even": "^1.0.0", 13 | "is-odd": "^3.0.1", 14 | "lib": "link:./shared", 15 | "lodash.zip": "^4.2.0", 16 | "pragmatic-drag-and-drop": "npm:@atlaskit/pragmatic-drag-and-drop@^1.5.2", 17 | "preact": "^10.26.5" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/tests/resolution.rs: -------------------------------------------------------------------------------- 1 | use std::path::{Path, PathBuf}; 2 | 3 | use crate::Resolution; 4 | 5 | #[test] 6 | fn test() { 7 | let resolution = Resolution { 8 | path: PathBuf::from("foo"), 9 | query: Some("?query".to_string()), 10 | fragment: Some("#fragment".to_string()), 11 | package_json: None, 12 | module_type: None, 13 | }; 14 | assert_eq!(resolution.path(), Path::new("foo")); 15 | assert_eq!(resolution.query(), Some("?query")); 16 | assert_eq!(resolution.fragment(), Some("#fragment")); 17 | assert_eq!(resolution.full_path(), PathBuf::from("foo?query#fragment")); 18 | assert_eq!(resolution.module_type(), None); 19 | assert_eq!(resolution.into_path_buf(), PathBuf::from("foo")); 20 | } 21 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/imports-exports-wildcard/node_modules/m/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "m", 3 | "exports": { 4 | "./features-no-ext/*": "./src/features/*", 5 | "./features/*.js": "./src/features/*.js", 6 | "./features/internal/*": null, 7 | "./middle/nested/f.js": "./src/middle/nested/f.js", 8 | "./middle-1/nested/*.js": "./src/middle-1/nested/*.js", 9 | "./middle-2/*/f.js": "./src/middle-2/*/f.js", 10 | "./middle-3/*": "./src/middle-3/*/*.js", 11 | "./middle-4/*/nested": "./src/middle-4/*/*.js", 12 | "./middle-5/*/$": "./src/middle-5/*/$.js" 13 | }, 14 | "imports": { 15 | "#internal/*.js": "./src/internal/*.js", 16 | "#/internal/*.js": "./src/internal/*.js", 17 | "#/*": "./src/*" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/cache/borrowed_path.rs: -------------------------------------------------------------------------------- 1 | use super::cached_path::CachedPath; 2 | use papaya::Equivalent; 3 | use std::{ 4 | hash::{Hash, Hasher}, 5 | path::Path, 6 | }; 7 | 8 | #[derive(Debug)] 9 | pub struct BorrowedCachedPath<'a> { 10 | pub hash: u64, 11 | pub path: &'a Path, 12 | } 13 | 14 | impl Equivalent for BorrowedCachedPath<'_> { 15 | fn equivalent(&self, other: &CachedPath) -> bool { 16 | self.path.as_os_str() == other.path().as_os_str() 17 | } 18 | } 19 | 20 | impl Hash for BorrowedCachedPath<'_> { 21 | fn hash(&self, state: &mut H) { 22 | self.hash.hash(state); 23 | } 24 | } 25 | 26 | impl PartialEq for BorrowedCachedPath<'_> { 27 | fn eq(&self, other: &Self) -> bool { 28 | self.path.as_os_str() == other.path.as_os_str() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /dprint.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://dprint.dev/schemas/v0.json", 3 | "lineWidth": 120, 4 | "typescript": { 5 | "quoteStyle": "preferSingle", 6 | "binaryExpression.operatorPosition": "sameLine" 7 | }, 8 | "json": { 9 | "indentWidth": 2 10 | }, 11 | "toml": { 12 | }, 13 | "excludes": [ 14 | "fixtures/**", 15 | "CHANGELOG.md", 16 | "pnpm-workspace.yaml", 17 | "pnpm-lock.yaml", 18 | "napi/*.{cjs,js,mjs,d.ts}", 19 | "!napi/test.mjs" 20 | ], 21 | "plugins": [ 22 | "https://plugins.dprint.dev/typescript-0.95.13.wasm", 23 | "https://plugins.dprint.dev/json-0.21.0.wasm", 24 | "https://plugins.dprint.dev/markdown-0.20.0.wasm", 25 | "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm", 26 | "https://plugins.dprint.dev/toml-0.7.0.wasm" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /napi/src/tracing.rs: -------------------------------------------------------------------------------- 1 | use std::sync::OnceLock; 2 | 3 | use tracing_subscriber::{ 4 | filter::Targets, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, 5 | }; 6 | 7 | /// To debug `oxc_resolver`: 8 | /// `OXC_LOG=DEBUG your program` 9 | pub fn init_tracing() { 10 | static TRACING: OnceLock<()> = OnceLock::new(); 11 | TRACING.get_or_init(|| { 12 | // Usage without the `regex` feature. 13 | // 14 | tracing_subscriber::registry() 15 | .with(std::env::var("OXC_LOG").map_or_else( 16 | |_| Targets::new(), 17 | |env_var| { 18 | use std::str::FromStr; 19 | Targets::from_str(&env_var).unwrap() 20 | }, 21 | )) 22 | .with(tracing_subscriber::fmt::layer()) 23 | .init(); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /napi/webcontainer-fallback.js: -------------------------------------------------------------------------------- 1 | const fs = require('node:fs'); 2 | const childProcess = require('node:child_process'); 3 | 4 | const pkg = JSON.parse( 5 | fs.readFileSync(require.resolve('oxc-resolver/package.json'), 'utf-8'), 6 | ); 7 | const version = pkg.version; 8 | const baseDir = `/tmp/oxc-resolver-${version}`; 9 | const bindingEntry = `${baseDir}/node_modules/@oxc-resolver/binding-wasm32-wasi/resolver.wasi.cjs`; 10 | 11 | if (!fs.existsSync(bindingEntry)) { 12 | fs.rmSync(baseDir, { recursive: true, force: true }); 13 | fs.mkdirSync(baseDir, { recursive: true }); 14 | const bindingPkg = `@oxc-resolver/binding-wasm32-wasi@${version}`; 15 | // eslint-disable-next-line: no-console 16 | console.log(`[oxc-resolver] Downloading ${bindingPkg} on WebContainer...`); 17 | childProcess.execFileSync('pnpm', ['i', bindingPkg], { 18 | cwd: baseDir, 19 | stdio: 'inherit', 20 | }); 21 | } 22 | 23 | module.exports = require(bindingEntry); 24 | -------------------------------------------------------------------------------- /src/tests/tsconfig_discovery.rs: -------------------------------------------------------------------------------- 1 | //! Tests for tsconfig discovery 2 | //! 3 | //! Tests that tsconfig.json can be auto-discovered when no explicit tsconfig option is provided. 4 | 5 | use crate::{ResolveError, ResolveOptions, Resolver, TsconfigDiscovery}; 6 | 7 | #[test] 8 | fn tsconfig_discovery() { 9 | super::tsconfig_paths::tsconfig_resolve_impl(/* tsconfig_discovery */ true); 10 | } 11 | 12 | #[test] 13 | fn tsconfig_discovery_virtual_file_importer() { 14 | let f = super::fixture_root().join("tsconfig"); 15 | 16 | let resolver = Resolver::new(ResolveOptions { 17 | tsconfig: Some(TsconfigDiscovery::Auto), 18 | cwd: Some(f.join("cases/index")), 19 | ..ResolveOptions::default() 20 | }); 21 | 22 | let resolved_path = 23 | resolver.resolve_file("\0virtual-module/foo.js", "random-import").map(|f| f.full_path()); 24 | assert_eq!(resolved_path, Err(ResolveError::NotFound("random-import".into()))); 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/enhanced-resolve/test/fixtures/browser-module/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "exports": { 3 | "./lib/index.js": "./lib/index.js" 4 | }, 5 | "browser": { 6 | "./lib/ignore.js": false, 7 | "./lib/replaced.js": "./lib/browser", 8 | "module-a": "./browser/module-a.js", 9 | "module-b": "module-c", 10 | "module-c": "module-c", 11 | "./toString": "./lib/toString.js", 12 | "./lib/main.js": "./lib/main.js", 13 | "./main.js": "./lib/main.js", 14 | "./lib/xyz.js": "./xyz.js", 15 | "./xyz.js": "./lib/xyz.js", 16 | "./lib/non-existent.js": "./lib/non-existent.js", 17 | ".": false, 18 | "./number": 1, 19 | "./foo": "./lib/replaced.js?query" 20 | }, 21 | "innerBrowser1": { 22 | "field": { 23 | "browser": { 24 | "./lib/main1.js": "./lib/main.js" 25 | } 26 | } 27 | }, 28 | "innerBrowser2": { 29 | "browser": { 30 | "./lib/main2.js": "./lib/replaced.js" 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /.github/workflows/deny.yml: -------------------------------------------------------------------------------- 1 | name: Cargo Deny 2 | 3 | permissions: {} 4 | 5 | on: 6 | workflow_dispatch: 7 | pull_request: 8 | types: 9 | - opened 10 | - synchronize 11 | paths: 12 | - "Cargo.lock" 13 | - "deny.toml" 14 | - ".github/workflows/deny.yml" 15 | push: 16 | branches: 17 | - main 18 | paths: 19 | - "Cargo.lock" 20 | - "deny.toml" 21 | - ".github/workflows/deny.yml" 22 | 23 | concurrency: 24 | group: ${{ github.workflow }}-${{ github.ref }} 25 | cancel-in-progress: true 26 | 27 | jobs: 28 | deny: 29 | name: Cargo Deny 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 33 | 34 | - uses: oxc-project/setup-rust@ecabb7322a2ba5aeedb3612d2a40b86a85cee235 # v1.0.11 35 | with: 36 | restore-cache: false 37 | tools: cargo-deny 38 | 39 | - run: cargo deny check 40 | -------------------------------------------------------------------------------- /napi/test.mjs: -------------------------------------------------------------------------------- 1 | import assert from 'assert'; 2 | import path from 'path'; 3 | import resolve, { ResolverFactory } from './index.js'; 4 | 5 | console.log(`Testing on ${process.platform}-${process.arch}`); 6 | 7 | const dir = import.meta.dirname; 8 | 9 | // `resolve` 10 | assert.deepStrictEqual( 11 | resolve.sync(dir, './index.js').path, 12 | path.join(dir, 'index.js'), 13 | ); 14 | 15 | // `ResolverFactory` 16 | const resolver = new ResolverFactory(); 17 | assert.deepStrictEqual( 18 | resolver.sync(dir, './index.js').path, 19 | path.join(dir, 'index.js'), 20 | ); 21 | 22 | assert.strict(resolver.sync(dir, './ts').error.length > 0); 23 | 24 | resolver 25 | .async(dir, './ts') 26 | .then((result) => assert.strict(result.error.length > 0)); 27 | 28 | const newResolver = resolver.cloneWithOptions({}); 29 | newResolver.clearCache(); 30 | 31 | // custom constructor 32 | const resolver2 = new ResolverFactory({ 33 | extensions: ['.mjs'], 34 | }); 35 | 36 | // After add `.ts` extension, resolver can resolve `ts` as `ts.ts` now 37 | assert.deepStrictEqual( 38 | resolver2.sync(dir, './test.mjs').path, 39 | path.join(dir, 'test.mjs'), 40 | ); 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024-present VoidZero Inc. & Contributors 4 | Copyright (c) 2023 Boshen 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /napi/wasi-worker-browser.mjs: -------------------------------------------------------------------------------- 1 | import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime' 2 | import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs' 3 | 4 | const fs = createFsProxy(__memfsExported) 5 | 6 | const handler = new MessageHandler({ 7 | onLoad({ wasmModule, wasmMemory }) { 8 | const wasi = new WASI({ 9 | fs, 10 | preopens: { 11 | '/': '/', 12 | }, 13 | print: function () { 14 | // eslint-disable-next-line no-console 15 | console.log.apply(console, arguments) 16 | }, 17 | printErr: function() { 18 | // eslint-disable-next-line no-console 19 | console.error.apply(console, arguments) 20 | }, 21 | }) 22 | return instantiateNapiModuleSync(wasmModule, { 23 | childThread: true, 24 | wasi, 25 | overwriteImports(importObject) { 26 | importObject.env = { 27 | ...importObject.env, 28 | ...importObject.napi, 29 | ...importObject.emnapi, 30 | memory: wasmMemory, 31 | } 32 | }, 33 | }) 34 | }, 35 | }) 36 | 37 | globalThis.onmessage = function (e) { 38 | handler.handle(e) 39 | } 40 | -------------------------------------------------------------------------------- /.github/workflows/zizmor.yml: -------------------------------------------------------------------------------- 1 | name: Zizmor 2 | 3 | permissions: {} 4 | 5 | on: 6 | workflow_dispatch: 7 | pull_request: 8 | types: 9 | - opened 10 | - synchronize 11 | paths: 12 | - ".github/workflows/**" 13 | push: 14 | branches: 15 | - main 16 | paths: 17 | - .github/workflows/** 18 | 19 | concurrency: 20 | group: ${{ github.workflow }}-${{ github.ref }} 21 | cancel-in-progress: true 22 | 23 | jobs: 24 | zizmor: 25 | name: zizmor 26 | runs-on: ubuntu-latest 27 | permissions: 28 | security-events: write 29 | steps: 30 | - uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 31 | 32 | - uses: taiki-e/install-action@61e5998d108b2b55a81b9b386c18bd46e4237e4f # v2.63.1 33 | with: 34 | tool: zizmor 35 | 36 | - name: Run zizmor 37 | run: zizmor --format sarif . > results.sarif 38 | env: 39 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | 41 | - name: Upload SARIF file 42 | uses: github/codeql-action/upload-sarif@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4.31.8 43 | with: 44 | sarif_file: results.sarif 45 | category: zizmor 46 | -------------------------------------------------------------------------------- /.github/actions/pnpm/action.yml: -------------------------------------------------------------------------------- 1 | name: Pnpm 2 | 3 | description: Install pnpm 4 | 5 | inputs: 6 | architecture: 7 | description: The architecture to use 8 | required: false 9 | cpu: 10 | description: The cpu architecture to use 11 | required: false 12 | 13 | runs: 14 | using: composite 15 | steps: 16 | - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 17 | 18 | - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 19 | with: 20 | node-version-file: .node-version 21 | architecture: ${{ inputs.architecture }} 22 | cache: pnpm 23 | 24 | - if: ${{ inputs.cpu }} 25 | shell: bash 26 | run: node -e 'console.log(`\nsupportedArchitectures:\n cpu:\n - ${process.env.CPU_ARCH}`)' >> pnpm-workspace.yaml 27 | env: 28 | CPU_ARCH: ${{ inputs.cpu }} 29 | 30 | - name: pnpm 31 | shell: bash 32 | run: | 33 | corepack enable 34 | pnpm install 35 | 36 | - name: yarn pnp 37 | shell: bash 38 | run: | 39 | cd fixtures/pnp 40 | yarn install 41 | 42 | cd ../global-pnp 43 | yarn install 44 | 45 | cd ../yarn 46 | yarn install 47 | -------------------------------------------------------------------------------- /src/tests/module_type.rs: -------------------------------------------------------------------------------- 1 | use crate::{ModuleType, ResolveOptions, Resolver}; 2 | 3 | #[test] 4 | fn test() { 5 | let f = super::fixture_root().join("misc").join("module-type"); 6 | 7 | let resolver = Resolver::new(ResolveOptions { module_type: true, ..ResolveOptions::default() }); 8 | 9 | let pass = [ 10 | ("./file.cjs", ModuleType::CommonJs), 11 | ("./file.mjs", ModuleType::Module), 12 | ("./file.node", ModuleType::Addon), 13 | ("./file.wasm", ModuleType::Wasm), 14 | ("./cjs/file.cjs", ModuleType::CommonJs), 15 | ("./cjs/file.mjs", ModuleType::Module), 16 | ("./cjs/file.js", ModuleType::CommonJs), 17 | ("./esm/file.cjs", ModuleType::CommonJs), 18 | ("./esm/file.mjs", ModuleType::Module), 19 | ("./esm/file.js", ModuleType::Module), 20 | ]; 21 | 22 | for (file, module_type) in pass { 23 | let resolution = resolver.resolve(&f, file).unwrap(); 24 | assert_eq!(resolution.module_type(), Some(module_type), "{file}"); 25 | } 26 | 27 | let fail = ["./file", "./file.ext", "./no/file.js"]; 28 | 29 | for file in fail { 30 | let resolution = resolver.resolve(&f, file).unwrap(); 31 | assert_eq!(resolution.module_type(), None); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /fixtures/yarn/yarn.lock: -------------------------------------------------------------------------------- 1 | # This file is generated by running "yarn install" inside your project. 2 | # Manual changes might be lost - proceed with caution! 3 | 4 | __metadata: 5 | version: 8 6 | cacheKey: 10c0 7 | 8 | "extension-alias@workspace:.": 9 | version: 0.0.0-use.local 10 | resolution: "extension-alias@workspace:." 11 | dependencies: 12 | typescript: "npm:^5.8.3" 13 | languageName: unknown 14 | linkType: soft 15 | 16 | "typescript@npm:^5.8.3": 17 | version: 5.8.3 18 | resolution: "typescript@npm:5.8.3" 19 | bin: 20 | tsc: bin/tsc 21 | tsserver: bin/tsserver 22 | checksum: 10c0/5f8bb01196e542e64d44db3d16ee0e4063ce4f3e3966df6005f2588e86d91c03e1fb131c2581baf0fb65ee79669eea6e161cd448178986587e9f6844446dbb48 23 | languageName: node 24 | linkType: hard 25 | 26 | "typescript@patch:typescript@npm%3A^5.8.3#optional!builtin": 27 | version: 5.8.3 28 | resolution: "typescript@patch:typescript@npm%3A5.8.3#optional!builtin::version=5.8.3&hash=5786d5" 29 | bin: 30 | tsc: bin/tsc 31 | tsserver: bin/tsserver 32 | checksum: 10c0/39117e346ff8ebd87ae1510b3a77d5d92dae5a89bde588c747d25da5c146603a99c8ee588c7ef80faaf123d89ed46f6dbd918d534d641083177d5fac38b8a1cb 33 | languageName: node 34 | linkType: hard 35 | -------------------------------------------------------------------------------- /.github/workflows/benchmark.yml: -------------------------------------------------------------------------------- 1 | name: Benchmark 2 | 3 | permissions: {} 4 | 5 | on: 6 | workflow_dispatch: 7 | pull_request: 8 | types: 9 | - opened 10 | - synchronize 11 | push: 12 | branches: 13 | - main 14 | 15 | concurrency: 16 | group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }} 17 | cancel-in-progress: ${{ github.ref_name != 'main' }} 18 | 19 | jobs: 20 | benchmark: 21 | name: Benchmark 22 | runs-on: ubuntu-latest 23 | permissions: 24 | id-token: write # required for OIDC authentication with CodSpeed 25 | steps: 26 | - uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 27 | 28 | - uses: oxc-project/setup-rust@ecabb7322a2ba5aeedb3612d2a40b86a85cee235 # v1.0.11 29 | with: 30 | cache-key: benchmark 31 | save-cache: ${{ github.ref_name == 'main' }} 32 | tools: cargo-codspeed 33 | 34 | - uses: ./.github/actions/pnpm 35 | 36 | - run: cargo codspeed build --features codspeed 37 | env: 38 | RUSTFLAGS: "-C debuginfo=1 -C strip=none" 39 | 40 | - uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1 41 | timeout-minutes: 30 42 | with: 43 | run: cargo codspeed run 44 | mode: instrumentation 45 | -------------------------------------------------------------------------------- /fixtures/global-pnp/yarn.lock: -------------------------------------------------------------------------------- 1 | # This file is generated by running "yarn install" inside your project. 2 | # Manual changes might be lost - proceed with caution! 3 | 4 | __metadata: 5 | version: 8 6 | cacheKey: 10c0 7 | 8 | "buffer-from@npm:^1.0.0": 9 | version: 1.1.2 10 | resolution: "buffer-from@npm:1.1.2" 11 | checksum: 10c0/124fff9d66d691a86d3b062eff4663fe437a9d9ee4b47b1b9e97f5a5d14f6d5399345db80f796827be7c95e70a8e765dd404b7c3ff3b3324f98e9b0c8826cc34 12 | languageName: node 13 | linkType: hard 14 | 15 | "global-pnp@workspace:.": 16 | version: 0.0.0-use.local 17 | resolution: "global-pnp@workspace:." 18 | dependencies: 19 | source-map-support: "npm:^0.5.21" 20 | languageName: unknown 21 | linkType: soft 22 | 23 | "source-map-support@npm:^0.5.21": 24 | version: 0.5.21 25 | resolution: "source-map-support@npm:0.5.21" 26 | dependencies: 27 | buffer-from: "npm:^1.0.0" 28 | source-map: "npm:^0.6.0" 29 | checksum: 10c0/9ee09942f415e0f721d6daad3917ec1516af746a8120bba7bb56278707a37f1eb8642bde456e98454b8a885023af81a16e646869975f06afc1a711fb90484e7d 30 | languageName: node 31 | linkType: hard 32 | 33 | "source-map@npm:^0.6.0": 34 | version: 0.6.1 35 | resolution: "source-map@npm:0.6.1" 36 | checksum: 10c0/ab55398007c5e5532957cb0beee2368529618ac0ab372d789806f5718123cc4367d57de3904b4e6a4170eb5a0b0f41373066d02ca0735a0c4d75c7d328d3e011 37 | languageName: node 38 | linkType: hard 39 | -------------------------------------------------------------------------------- /src/tests/main_field.rs: -------------------------------------------------------------------------------- 1 | //! Not part of enhanced_resolve's test suite 2 | 3 | use crate::{ResolveOptions, Resolver}; 4 | 5 | #[test] 6 | fn test() { 7 | let f = super::fixture().join("restrictions"); 8 | 9 | let resolver1 = Resolver::new(ResolveOptions { 10 | main_fields: vec!["style".into()], 11 | ..ResolveOptions::default() 12 | }); 13 | 14 | let resolution = resolver1.resolve(&f, "pck2").map(|r| r.full_path()); 15 | assert_eq!(resolution, Ok(f.join("node_modules/pck2/index.css"))); 16 | 17 | let resolver2 = resolver1.clone_with_options(ResolveOptions { 18 | main_fields: vec!["module".into(), "main".into()], 19 | ..ResolveOptions::default() 20 | }); 21 | 22 | let resolution = resolver2.resolve(&f, "pck2").map(|r| r.full_path()); 23 | assert_eq!(resolution, Ok(f.join("node_modules/pck2/module.js"))); 24 | } 25 | 26 | #[test] 27 | fn test_fallback() { 28 | let f = super::fixture_root().join("invalid"); 29 | 30 | let resolver1 = Resolver::new(ResolveOptions { 31 | main_fields: vec!["module".into(), "main".into()], 32 | extension_alias: vec![(".js".into(), vec![".ts".into(), ".js".into()])], 33 | ..ResolveOptions::default() 34 | }); 35 | 36 | let resolution = resolver1.resolve(&f, "main_field_fallback").map(|r| r.full_path()); 37 | assert_eq!(resolution, Ok(f.join("node_modules/main_field_fallback/exist.js"))); 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/clear_cache.rs: -------------------------------------------------------------------------------- 1 | use std::{env, fs}; 2 | 3 | use rayon::prelude::*; 4 | 5 | use crate::Resolver; 6 | 7 | #[test] 8 | fn test_parallel_resolve_with_clear_cache() { 9 | let target_dir = env::current_dir().unwrap().join("./target"); 10 | let test_dir = target_dir.join("test_clear_cache"); 11 | let node_modules = test_dir.join("node_modules"); 12 | 13 | let _ = fs::remove_dir_all(&test_dir); 14 | fs::create_dir_all(&node_modules).unwrap(); 15 | 16 | let packages: Vec = (1..=100).map(|i| format!("package_{i}")).collect(); 17 | for package in &packages { 18 | let package_dir = node_modules.join(package); 19 | fs::create_dir_all(&package_dir).unwrap(); 20 | let package_json = format!(r#"{{"name": "{package}", "main": "index.js"}}"#); 21 | fs::write(package_dir.join("package.json"), package_json).unwrap(); 22 | fs::write(package_dir.join("index.js"), "").unwrap(); 23 | } 24 | 25 | let resolver = Resolver::default(); 26 | for _ in 1..100 { 27 | packages.par_iter().enumerate().for_each(|(i, package)| { 28 | if i % 10 == 0 && i > 0 { 29 | resolver.clear_cache(); 30 | } 31 | let result = resolver.resolve(&test_dir, package); 32 | assert!(result.is_ok(), "Failed to resolve {package}: {result:?}"); 33 | }); 34 | } 35 | 36 | let _ = fs::remove_dir_all(&test_dir); 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/scoped_packages.rs: -------------------------------------------------------------------------------- 1 | //! 2 | 3 | use crate::{Resolution, ResolveOptions, Resolver}; 4 | 5 | #[test] 6 | fn scoped_packages() { 7 | let f = super::fixture().join("scoped"); 8 | 9 | let resolver = Resolver::new(ResolveOptions { 10 | alias_fields: vec![vec!["browser".into()]], 11 | ..ResolveOptions::default() 12 | }); 13 | 14 | #[rustfmt::skip] 15 | let pass = [ 16 | ("main field should work", f.clone(), "@scope/pack1", "@scope/pack1", f.join("./node_modules/@scope/pack1/main.js")), 17 | ("browser field should work", f.clone(), "@scope/pack2", "@scope/pack2", f.join("./node_modules/@scope/pack2/main.js")), 18 | ("folder request should work", f.clone(), "@scope/pack2/lib", "@scope/pack2", f.join("./node_modules/@scope/pack2/lib/index.js")) 19 | ]; 20 | 21 | for (comment, path, request, package, expected) in pass { 22 | let resolution = resolver.resolve(&path, request).ok(); 23 | let resolved_path = resolution.as_ref().map(Resolution::full_path); 24 | let resolved_package_json = 25 | resolution.as_ref().and_then(|r| r.package_json()).map(|p| p.path.clone()); 26 | assert_eq!(resolved_path, Some(expected), "{comment} {path:?} {request}"); 27 | let package_json_path = f.join("node_modules").join(package).join("package.json"); 28 | assert_eq!(resolved_package_json, Some(package_json_path), "{path:?} {request}"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.github/workflows/autofix.yml: -------------------------------------------------------------------------------- 1 | name: autofix.ci # For security reasons, the workflow in which the autofix.ci action is used must be named "autofix.ci". 2 | 3 | permissions: {} 4 | 5 | on: 6 | pull_request: 7 | types: 8 | - opened 9 | - synchronize 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | autofix: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 20 | 21 | - uses: oxc-project/setup-rust@ecabb7322a2ba5aeedb3612d2a40b86a85cee235 # v1.0.11 22 | with: 23 | restore-cache: false 24 | tools: just,cargo-shear@1,dprint 25 | components: rustfmt 26 | 27 | - name: Restore dprint plugin cache 28 | id: cache-restore 29 | uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 30 | with: 31 | key: dprint-autofix-ci-${{ runner.os }}-${{ hashFiles('dprint.json') }} 32 | path: ~/.cache/dprint 33 | 34 | - run: just fmt 35 | 36 | - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # v1.3.2 37 | with: 38 | fail-fast: false 39 | 40 | - name: Save dprint plugin cache 41 | if: ${{ github.ref_name == 'main' }} 42 | id: cache-save 43 | uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 44 | with: 45 | key: ${{ steps.cache-restore.outputs.cache-primary-key }} 46 | path: ~/.cache/dprint 47 | -------------------------------------------------------------------------------- /src/cache/mod.rs: -------------------------------------------------------------------------------- 1 | mod borrowed_path; 2 | mod cache_impl; 3 | mod cached_path; 4 | mod hasher; 5 | mod thread_local; 6 | 7 | pub use cache_impl::Cache; 8 | pub use cached_path::CachedPath; 9 | 10 | #[cfg(test)] 11 | mod tests { 12 | use super::borrowed_path::BorrowedCachedPath; 13 | use super::cache_impl::Cache; 14 | use crate::FileSystem; 15 | use std::path::Path; 16 | 17 | #[test] 18 | fn test_borrowed_cached_path_eq() { 19 | let path1 = Path::new("/foo/bar"); 20 | let path2 = Path::new("/foo/bar"); 21 | let path3 = Path::new("/foo/baz"); 22 | 23 | let borrowed1 = BorrowedCachedPath { hash: 1, path: path1 }; 24 | let borrowed2 = BorrowedCachedPath { hash: 2, path: path2 }; 25 | let borrowed3 = BorrowedCachedPath { hash: 1, path: path3 }; 26 | 27 | // Same path should be equal even with different hash 28 | assert_eq!(borrowed1, borrowed2); 29 | // Different path should not be equal even with same hash 30 | assert_ne!(borrowed1, borrowed3); 31 | } 32 | 33 | #[test] 34 | fn test_cached_path_debug() { 35 | #[cfg(feature = "yarn_pnp")] 36 | let cache = Cache::new(crate::FileSystemOs::new(false)); 37 | #[cfg(not(feature = "yarn_pnp"))] 38 | let cache = Cache::new(crate::FileSystemOs::new()); 39 | 40 | let path = Path::new("/foo/bar"); 41 | let cached_path = cache.value(path); 42 | assert!(format!("{cached_path:?}") == format!("{path:?}")); 43 | assert!(format!("{cached_path}") == format!("{}", path.display())); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod alias; 2 | mod browser_field; 3 | mod builtins; 4 | mod clear_cache; 5 | mod dependencies; 6 | mod exports_field; 7 | mod extension_alias; 8 | mod extensions; 9 | mod fallback; 10 | mod full_specified; 11 | mod imports_field; 12 | mod incorrect_description_file; 13 | mod main_field; 14 | mod memory_fs; 15 | mod memory_leak; 16 | mod missing; 17 | mod module_type; 18 | mod package_json; 19 | #[cfg(feature = "yarn_pnp")] 20 | mod pnp; 21 | mod resolution; 22 | mod resolve; 23 | mod restrictions; 24 | mod roots; 25 | mod scoped_packages; 26 | mod simple; 27 | mod symlink; 28 | mod tsconfck; 29 | mod tsconfig_discovery; 30 | mod tsconfig_extends; 31 | mod tsconfig_paths; 32 | mod tsconfig_project_references; 33 | mod tsconfig_root_dirs; 34 | #[cfg(target_os = "windows")] 35 | mod windows; 36 | 37 | use std::{env, path::PathBuf, sync::Arc, thread}; 38 | 39 | use crate::Resolver; 40 | 41 | pub fn fixture_root() -> PathBuf { 42 | env::current_dir().unwrap().join("fixtures") 43 | } 44 | 45 | pub fn fixture() -> PathBuf { 46 | fixture_root().join("enhanced-resolve").join("test").join("fixtures") 47 | } 48 | 49 | #[test] 50 | #[cfg_attr(target_os = "wasi", ignore)] 51 | fn threaded_environment() { 52 | let cwd = env::current_dir().unwrap(); 53 | let resolver = Arc::new(Resolver::default()); 54 | for _ in 0..2 { 55 | _ = thread::spawn({ 56 | let cwd = cwd.clone(); 57 | let resolver = Arc::clone(&resolver); 58 | move || { 59 | _ = resolver.resolve(cwd, "."); 60 | } 61 | }) 62 | .join(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/builtins.rs: -------------------------------------------------------------------------------- 1 | /// Node.js built-in modules 2 | /// 3 | /// `node -p "[...require('module').builtinModules].map(b => JSON.stringify(b)).join(',\n')"` 4 | /// 5 | pub const NODEJS_BUILTINS: &[&str] = &[ 6 | "_http_agent", 7 | "_http_client", 8 | "_http_common", 9 | "_http_incoming", 10 | "_http_outgoing", 11 | "_http_server", 12 | "_stream_duplex", 13 | "_stream_passthrough", 14 | "_stream_readable", 15 | "_stream_transform", 16 | "_stream_wrap", 17 | "_stream_writable", 18 | "_tls_common", 19 | "_tls_wrap", 20 | "assert", 21 | "assert/strict", 22 | "async_hooks", 23 | "buffer", 24 | "child_process", 25 | "cluster", 26 | "console", 27 | "constants", 28 | "crypto", 29 | "dgram", 30 | "diagnostics_channel", 31 | "dns", 32 | "dns/promises", 33 | "domain", 34 | "events", 35 | "fs", 36 | "fs/promises", 37 | "http", 38 | "http2", 39 | "https", 40 | "inspector", 41 | "module", 42 | "net", 43 | "os", 44 | "path", 45 | "path/posix", 46 | "path/win32", 47 | "perf_hooks", 48 | "process", 49 | "punycode", 50 | "querystring", 51 | "readline", 52 | "repl", 53 | "stream", 54 | "stream/consumers", 55 | "stream/promises", 56 | "stream/web", 57 | "string_decoder", 58 | "sys", 59 | "timers", 60 | "timers/promises", 61 | "tls", 62 | "trace_events", 63 | "tty", 64 | "url", 65 | "util", 66 | "util/types", 67 | "v8", 68 | "vm", 69 | "worker_threads", 70 | "zlib", 71 | ]; 72 | -------------------------------------------------------------------------------- /.github/workflows/copilot-setup-steps.yml: -------------------------------------------------------------------------------- 1 | name: Copilot Setup Steps 2 | 3 | # This workflow defines the setup steps that GitHub Copilot agents will use 4 | # to prepare the development environment for the oxc project. 5 | # It preinstalls tools and dependencies needed for Rust and Node.js development. 6 | 7 | on: 8 | workflow_dispatch: 9 | pull_request: 10 | types: [opened, synchronize] 11 | paths: 12 | - .github/workflows/copilot-setup-steps.yml 13 | push: 14 | branches: 15 | - main 16 | paths: 17 | - .github/workflows/copilot-setup-steps.yml 18 | 19 | permissions: {} 20 | 21 | jobs: 22 | copilot-setup-steps: 23 | name: Setup Development Environment for Copilot 24 | runs-on: ubuntu-latest 25 | steps: 26 | # Checkout full repo for git history. 27 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 28 | with: 29 | persist-credentials: false 30 | 31 | - uses: oxc-project/setup-rust@ecabb7322a2ba5aeedb3612d2a40b86a85cee235 # v1.0.11 32 | with: 33 | cache-key: warm 34 | save-cache: false 35 | tools: just,watchexec-cli,cargo-insta,typos-cli,cargo-shear,dprint 36 | components: clippy rust-docs rustfmt 37 | 38 | - uses: oxc-project/setup-node@141eb77546de6702f92d320926403fe3f9f6a6f2 # v1.0.5 39 | 40 | - uses: ./.github/actions/pnpm 41 | 42 | - name: Restore dprint plugin cache 43 | id: cache-restore 44 | uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 45 | with: 46 | key: dprint-${{ hashFiles('dprint.json') }} 47 | path: ~/.cache/dprint 48 | -------------------------------------------------------------------------------- /napi/wasi-worker.mjs: -------------------------------------------------------------------------------- 1 | import fs from "node:fs"; 2 | import { createRequire } from "node:module"; 3 | import { parse } from "node:path"; 4 | import { WASI } from "node:wasi"; 5 | import { parentPort, Worker } from "node:worker_threads"; 6 | 7 | const require = createRequire(import.meta.url); 8 | 9 | const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime"); 10 | 11 | if (parentPort) { 12 | parentPort.on("message", (data) => { 13 | globalThis.onmessage({ data }); 14 | }); 15 | } 16 | 17 | Object.assign(globalThis, { 18 | self: globalThis, 19 | require, 20 | Worker, 21 | importScripts: function (f) { 22 | ;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f); 23 | }, 24 | postMessage: function (msg) { 25 | if (parentPort) { 26 | parentPort.postMessage(msg); 27 | } 28 | }, 29 | }); 30 | 31 | const emnapiContext = getDefaultContext(); 32 | 33 | const __rootDir = parse(process.cwd()).root; 34 | 35 | const handler = new MessageHandler({ 36 | onLoad({ wasmModule, wasmMemory }) { 37 | const wasi = new WASI({ 38 | version: 'preview1', 39 | env: process.env, 40 | preopens: { 41 | [__rootDir]: __rootDir, 42 | }, 43 | }); 44 | 45 | return instantiateNapiModuleSync(wasmModule, { 46 | childThread: true, 47 | wasi, 48 | context: emnapiContext, 49 | overwriteImports(importObject) { 50 | importObject.env = { 51 | ...importObject.env, 52 | ...importObject.napi, 53 | ...importObject.emnapi, 54 | memory: wasmMemory 55 | }; 56 | }, 57 | }); 58 | }, 59 | }); 60 | 61 | globalThis.onmessage = function (e) { 62 | handler.handle(e); 63 | }; 64 | -------------------------------------------------------------------------------- /examples/file.rs: -------------------------------------------------------------------------------- 1 | // See documentation at 2 | 3 | use std::path::PathBuf; 4 | 5 | use oxc_resolver::{AliasValue, ResolveOptions, Resolver, TsconfigDiscovery}; 6 | use pico_args::Arguments; 7 | 8 | fn main() { 9 | let mut args = Arguments::from_env(); 10 | 11 | let path = args.free_from_str::().expect("path"); 12 | let specifier = args.free_from_str::().expect("specifier"); 13 | 14 | assert!(path.is_file(), "{} must be a file that will be resolved against.", path.display()); 15 | assert!(path.is_absolute(), "{} must be an absolute path.", path.display()); 16 | 17 | println!("path: {}", path.to_string_lossy()); 18 | println!("specifier: {specifier}"); 19 | 20 | let options = ResolveOptions { 21 | alias_fields: vec![vec!["browser".into()]], 22 | alias: vec![("asdf".into(), vec![AliasValue::from("./test.js")])], 23 | extensions: vec![".js".into(), ".ts".into()], 24 | extension_alias: vec![(".js".into(), vec![".ts".into(), ".js".into()])], 25 | // ESM 26 | condition_names: vec!["node".into(), "import".into()], 27 | // CJS 28 | // condition_names: vec!["node".into(), "require".into()], 29 | tsconfig: Some(TsconfigDiscovery::Auto), 30 | ..ResolveOptions::default() 31 | }; 32 | 33 | println!(); 34 | 35 | match Resolver::new(options).resolve_file(path, &specifier) { 36 | Err(error) => println!("Error: {error}"), 37 | Ok(resolution) => { 38 | println!("Resolution: {}", resolution.full_path().to_string_lossy()); 39 | println!("Module Type: {:?}", resolution.module_type()); 40 | println!( 41 | "package.json: {:?}", 42 | resolution.package_json().map(|p| p.path.to_string_lossy()) 43 | ); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /napi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "oxc_resolver_napi" 3 | version = "11.15.0" 4 | authors.workspace = true 5 | categories.workspace = true 6 | edition.workspace = true 7 | homepage.workspace = true 8 | include = ["src", "build.rs"] 9 | keywords.workspace = true 10 | license.workspace = true 11 | publish = true 12 | readme.workspace = true 13 | repository.workspace = true 14 | rust-version.workspace = true 15 | description.workspace = true 16 | 17 | [lib] 18 | crate-type = ["cdylib", "lib"] 19 | test = false 20 | doctest = false 21 | 22 | [dependencies] 23 | oxc_resolver = { workspace = true } 24 | 25 | fancy-regex = { version = "^0.17.0", default-features = false, features = ["std"] } 26 | napi = { version = "3", default-features = false, features = ["napi3", "serde-json"] } 27 | napi-derive = { version = "3" } 28 | tracing-subscriber = { version = "0.3.20", optional = true, default-features = false, features = ["std", "fmt"] } # Omit the `regex` feature 29 | 30 | [target.'cfg(not(any(target_os = "linux", target_os = "freebsd", target_arch = "arm", target_family = "wasm")))'.dependencies] 31 | mimalloc-safe = { version = "0.1.55", optional = true, features = ["skip_collect_on_exit"] } 32 | 33 | [target.'cfg(all(target_os = "linux", not(target_arch = "arm"), not(target_arch = "aarch64")))'.dependencies] 34 | mimalloc-safe = { version = "0.1.55", optional = true, features = ["skip_collect_on_exit", "local_dynamic_tls"] } 35 | 36 | [target.'cfg(all(target_os = "linux", target_arch = "aarch64"))'.dependencies] 37 | mimalloc-safe = { version = "0.1.55", optional = true, features = ["skip_collect_on_exit", "local_dynamic_tls", "no_opt_arch"] } 38 | 39 | [build-dependencies] 40 | napi-build = "2.3.0" 41 | 42 | [features] 43 | default = ["tracing-subscriber", "yarn_pnp"] 44 | allocator = ["dep:mimalloc-safe"] 45 | tracing-subscriber = ["dep:tracing-subscriber"] 46 | yarn_pnp = ["oxc_resolver/yarn_pnp"] 47 | -------------------------------------------------------------------------------- /napi/tests/simple.test.mjs: -------------------------------------------------------------------------------- 1 | import { join } from 'node:path'; 2 | import { fileURLToPath } from 'node:url'; 3 | import { assert, test } from 'vitest'; 4 | 5 | import resolve, { ModuleType, ResolverFactory } from '../index.js'; 6 | 7 | const cwd = join(fileURLToPath(import.meta.url), '..', '..'); 8 | 9 | test('simple', () => { 10 | // `resolve` 11 | assert.equal(resolve.sync(cwd, './index.js').path, join(cwd, 'index.js')); 12 | 13 | // `ResolverFactory` 14 | const resolver = new ResolverFactory(); 15 | assert.equal(resolver.sync(cwd, './index.js').path, join(cwd, 'index.js')); 16 | 17 | assert.isAbove(resolver.sync(cwd, './ts').error.length, 0); 18 | 19 | resolver 20 | .async(cwd, './ts') 21 | .then((result) => assert.isAbove(result.error.length, 0)); 22 | 23 | // Test API 24 | const newResolver = resolver.cloneWithOptions({}); 25 | newResolver.clearCache(); 26 | }); 27 | 28 | test('module_type', () => { 29 | const dir = join(cwd, '..', 'fixtures', 'pnpm'); 30 | 31 | const esmResolver = new ResolverFactory({ 32 | conditionNames: ['node', 'import'], 33 | moduleType: true, 34 | }); 35 | 36 | assert.equal( 37 | esmResolver.sync(dir, 'minimatch').moduleType, 38 | ModuleType.Module, 39 | ); 40 | 41 | const cjsResolver = esmResolver.cloneWithOptions({ 42 | conditionNames: ['node', 'require'], 43 | moduleType: true, 44 | }); 45 | 46 | assert.equal( 47 | cjsResolver.sync(dir, 'minimatch').moduleType, 48 | ModuleType.CommonJs, 49 | ); 50 | }); 51 | 52 | test('builtin', () => { 53 | const resolver = new ResolverFactory({ 54 | builtinModules: true, 55 | }); 56 | assert.deepEqual(resolver.sync('/', 'fs').builtin, { 57 | resolved: 'node:fs', 58 | isRuntimeModule: false, 59 | }); 60 | assert.deepEqual(resolver.sync('/', 'node:fs').builtin, { 61 | resolved: 'node:fs', 62 | isRuntimeModule: true, 63 | }); 64 | }); 65 | -------------------------------------------------------------------------------- /src/tests/incorrect_description_file.rs: -------------------------------------------------------------------------------- 1 | //! 2 | 3 | use rustc_hash::FxHashSet; 4 | 5 | use crate::{JSONError, ResolveContext, ResolveError, Resolver}; 6 | 7 | // should not resolve main in incorrect description file #1 8 | #[test] 9 | fn incorrect_description_file_1() { 10 | let f = super::fixture().join("incorrect-package"); 11 | let mut ctx = ResolveContext::default(); 12 | let error = 13 | Resolver::default().resolve_with_context(f.join("pack1"), ".", None, &mut ctx).unwrap_err(); 14 | match error { 15 | ResolveError::Json(e) => { 16 | assert_eq!(e.path, f.join("pack1/package.json")); 17 | // Verify that we get proper error details from serde_json fallback 18 | assert!(e.message.contains("EOF")); 19 | assert!(e.line > 0); 20 | } 21 | _ => panic!("must be a json error."), 22 | } 23 | assert_eq!(ctx.file_dependencies, FxHashSet::from_iter([f.join("pack1/package.json")])); 24 | assert!(ctx.missing_dependencies.is_empty()); 25 | } 26 | 27 | // should not resolve main in incorrect description file #2 28 | #[test] 29 | fn incorrect_description_file_2() { 30 | let f = super::fixture().join("incorrect-package"); 31 | let resolution = Resolver::default().resolve(f.join("pack2"), "."); 32 | let error = ResolveError::Json(JSONError { 33 | path: f.join("pack2/package.json"), 34 | message: String::from("File is empty"), 35 | line: 0, 36 | column: 0, 37 | }); 38 | assert_eq!(resolution, Err(error)); 39 | } 40 | 41 | // should not resolve main in incorrect description file #3 42 | #[test] 43 | fn incorrect_description_file_3() { 44 | let f = super::fixture().join("incorrect-package"); 45 | let resolution = Resolver::default().resolve(f.join("pack2"), "."); 46 | assert!(resolution.is_err()); 47 | } 48 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release Plz 2 | 3 | permissions: {} 4 | 5 | on: 6 | workflow_dispatch: 7 | push: 8 | branches: 9 | - main 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | release-plz: 17 | name: Release-plz 18 | runs-on: ubuntu-latest 19 | permissions: 20 | pull-requests: write 21 | contents: write 22 | id-token: write 23 | steps: 24 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 25 | with: 26 | fetch-depth: 0 27 | token: ${{ secrets.OXC_BOT_PAT }} 28 | persist-credentials: true # required by release-plz 29 | 30 | - uses: oxc-project/release-plz-action@12ee013e577af39a0b75f282e04064658afca86e # v1.0.1 31 | id: release-plz 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.OXC_BOT_PAT }} 34 | 35 | - uses: oxc-project/setup-rust@ecabb7322a2ba5aeedb3612d2a40b86a85cee235 # v1.0.11 36 | with: 37 | cache-key: warm 38 | 39 | - uses: ./.github/actions/pnpm 40 | 41 | - name: Bump package.json 42 | if: ${{ steps.release-plz.outputs.prs_created }} 43 | env: 44 | GH_TOKEN: ${{ secrets.OXC_BOT_PAT }} 45 | PR_NUMBER: ${{ fromJSON(steps.release-plz.outputs.pr).number }} 46 | VERSION: ${{ fromJSON(steps.release-plz.outputs.pr).releases[0].version }} 47 | run: | 48 | set -e 49 | 50 | pr_number="${PR_NUMBER}" 51 | 52 | if [[ -n "$pr_number" ]]; then 53 | version="${VERSION}" 54 | 55 | jq --arg version "${version}" '.version = ($version)' package.json > tmp 56 | mv tmp package.json 57 | pnpm build 58 | 59 | gh pr checkout $pr_number 60 | git add . 61 | git commit --amend --no-edit 62 | git push --force-with-lease 63 | fi 64 | -------------------------------------------------------------------------------- /src/package_json/mod.rs: -------------------------------------------------------------------------------- 1 | //! package.json definitions 2 | //! 3 | //! This module provides platform-specific implementations for parsing package.json files. 4 | //! On little-endian systems, it uses simd-json for high performance. 5 | //! On big-endian systems, it falls back to serde_json. 6 | 7 | #[cfg(target_endian = "big")] 8 | mod serde; 9 | #[cfg(target_endian = "little")] 10 | mod simd; 11 | 12 | #[cfg(target_endian = "big")] 13 | pub use serde::*; 14 | #[cfg(target_endian = "little")] 15 | pub use simd::*; 16 | 17 | use std::{fmt, path::Path}; 18 | 19 | use crate::JSONError; 20 | 21 | /// Check if JSON content is empty or contains only whitespace 22 | fn check_if_empty(json_bytes: &[u8], path: &Path) -> Result<(), JSONError> { 23 | // Check if content is empty or whitespace-only 24 | if json_bytes.iter().all(|&b| b.is_ascii_whitespace()) { 25 | return Err(JSONError { 26 | path: path.to_path_buf(), 27 | message: "File is empty".to_string(), 28 | line: 0, 29 | column: 0, 30 | }); 31 | } 32 | Ok(()) 33 | } 34 | 35 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] 36 | pub enum PackageType { 37 | CommonJs, 38 | Module, 39 | } 40 | 41 | impl PackageType { 42 | pub(super) fn from_str(s: &str) -> Option { 43 | match s { 44 | "commonjs" => Some(Self::CommonJs), 45 | "module" => Some(Self::Module), 46 | _ => None, 47 | } 48 | } 49 | } 50 | 51 | impl fmt::Display for PackageType { 52 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 53 | match self { 54 | Self::CommonJs => f.write_str("commonjs"), 55 | Self::Module => f.write_str("module"), 56 | } 57 | } 58 | } 59 | 60 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] 61 | pub enum ImportsExportsKind { 62 | String, 63 | Array, 64 | Map, 65 | Invalid, 66 | } 67 | 68 | #[derive(Clone, Debug, Eq, PartialEq)] 69 | pub enum SideEffects<'a> { 70 | Bool(bool), 71 | String(&'a str), 72 | Array(Vec<&'a str>), 73 | } 74 | -------------------------------------------------------------------------------- /napi/resolver.wasi-browser.js: -------------------------------------------------------------------------------- 1 | import { 2 | createOnMessage as __wasmCreateOnMessageForFsProxy, 3 | getDefaultContext as __emnapiGetDefaultContext, 4 | instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, 5 | WASI as __WASI, 6 | } from '@napi-rs/wasm-runtime' 7 | import { memfs } from '@napi-rs/wasm-runtime/fs' 8 | 9 | 10 | export const { fs: __fs, vol: __volume } = memfs() 11 | 12 | const __wasi = new __WASI({ 13 | version: 'preview1', 14 | fs: __fs, 15 | preopens: { 16 | '/': '/', 17 | }, 18 | }) 19 | 20 | const __wasmUrl = new URL('./resolver.wasm32-wasi.wasm', import.meta.url).href 21 | const __emnapiContext = __emnapiGetDefaultContext() 22 | 23 | 24 | const __sharedMemory = new WebAssembly.Memory({ 25 | initial: 4000, 26 | maximum: 65536, 27 | shared: true, 28 | }) 29 | 30 | const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer()) 31 | 32 | const { 33 | instance: __napiInstance, 34 | module: __wasiModule, 35 | napiModule: __napiModule, 36 | } = __emnapiInstantiateNapiModuleSync(__wasmFile, { 37 | context: __emnapiContext, 38 | asyncWorkPoolSize: 4, 39 | wasi: __wasi, 40 | onCreateWorker() { 41 | const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), { 42 | type: 'module', 43 | }) 44 | worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs)) 45 | 46 | return worker 47 | }, 48 | overwriteImports(importObject) { 49 | importObject.env = { 50 | ...importObject.env, 51 | ...importObject.napi, 52 | ...importObject.emnapi, 53 | memory: __sharedMemory, 54 | } 55 | return importObject 56 | }, 57 | beforeInit({ instance }) { 58 | for (const name of Object.keys(instance.exports)) { 59 | if (name.startsWith('__napi_register__')) { 60 | instance.exports[name]() 61 | } 62 | } 63 | }, 64 | }) 65 | export default __napiModule.exports 66 | export const ResolverFactory = __napiModule.exports.ResolverFactory 67 | export const EnforceExtension = __napiModule.exports.EnforceExtension 68 | export const ModuleType = __napiModule.exports.ModuleType 69 | export const sync = __napiModule.exports.sync 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oxc-resolver", 3 | "version": "11.15.0", 4 | "license": "MIT", 5 | "description": "Oxc Resolver Node API", 6 | "packageManager": "pnpm@10.25.0", 7 | "homepage": "https://oxc.rs", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/oxc-project/oxc-resolver.git" 11 | }, 12 | "funding": { 13 | "url": "https://github.com/sponsors/Boshen" 14 | }, 15 | "main": "index.js", 16 | "browser": "browser.js", 17 | "files": [ 18 | "index.d.ts", 19 | "index.js", 20 | "browser.js", 21 | "webcontainer-fallback.js" 22 | ], 23 | "scripts": { 24 | "test": "vitest run -r ./napi", 25 | "build:debug": "napi build --platform --manifest-path napi/Cargo.toml", 26 | "build": "pnpm run build:debug --features allocator --release", 27 | "postbuild:debug": "node napi/patch.mjs" 28 | }, 29 | "devDependencies": { 30 | "@napi-rs/cli": "^3.3.1", 31 | "@napi-rs/wasm-runtime": "^1.0.7", 32 | "@types/node": "^25.0.0", 33 | "emnapi": "^1.6.0", 34 | "typescript": "^5.9.3", 35 | "vitest": "^4.0.0" 36 | }, 37 | "publishConfig": { 38 | "registry": "https://registry.npmjs.org/", 39 | "access": "public" 40 | }, 41 | "napi": { 42 | "binaryName": "resolver", 43 | "packageName": "@oxc-resolver/binding", 44 | "wasm": { 45 | "browser": { 46 | "fs": true 47 | } 48 | }, 49 | "targets": [ 50 | "aarch64-apple-darwin", 51 | "aarch64-linux-android", 52 | "aarch64-pc-windows-msvc", 53 | "aarch64-unknown-linux-gnu", 54 | "aarch64-unknown-linux-musl", 55 | "aarch64-unknown-linux-ohos", 56 | "armv7-linux-androideabi", 57 | "armv7-unknown-linux-gnueabihf", 58 | "armv7-unknown-linux-musleabihf", 59 | "i686-pc-windows-msvc", 60 | "powerpc64le-unknown-linux-gnu", 61 | "riscv64gc-unknown-linux-gnu", 62 | "riscv64gc-unknown-linux-musl", 63 | "s390x-unknown-linux-gnu", 64 | "wasm32-wasip1-threads", 65 | "x86_64-apple-darwin", 66 | "x86_64-pc-windows-msvc", 67 | "x86_64-unknown-freebsd", 68 | "x86_64-unknown-linux-gnu", 69 | "x86_64-unknown-linux-musl" 70 | ] 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /napi/tests/options.test.mjs: -------------------------------------------------------------------------------- 1 | import * as path from 'node:path'; 2 | import { assert, describe, it } from 'vitest'; 3 | 4 | import { ResolverFactory } from '../index.js'; 5 | import { normalizePath } from './utils.mjs'; 6 | 7 | const fixtureDir = path.resolve( 8 | import.meta.dirname, 9 | '../../fixtures/enhanced-resolve/test/fixtures', 10 | ); 11 | 12 | describe('option', () => { 13 | describe('aliasFields', () => { 14 | it('should allow field string ', () => { 15 | const resolver = new ResolverFactory({ aliasFields: ['browser'] }); 16 | assert.match( 17 | normalizePath(resolver.sync(fixtureDir, './browser-module/lib/replaced.js').path), 18 | /browser-module\/lib\/browser\.js$/, 19 | ); 20 | }); 21 | it('should allow json path array', () => { 22 | const resolver = new ResolverFactory({ 23 | aliasFields: [['innerBrowser1', 'field', 'browser']], 24 | }); 25 | 26 | assert.match( 27 | normalizePath(resolver.sync(fixtureDir, './browser-module/lib/main1.js').path), 28 | /browser-module\/lib\/main\.js$/, 29 | ); 30 | }); 31 | }); 32 | 33 | describe('exportsFields', () => { 34 | const createTest = (exportsFields) => { 35 | const resolver = new ResolverFactory({ exportsFields }); 36 | assert.match( 37 | normalizePath( 38 | resolver.sync( 39 | path.resolve(fixtureDir, './exports-field3'), 40 | 'exports-field', 41 | ).path, 42 | ), 43 | /\/exports-field\/src\/index\.js$/, 44 | ); 45 | }; 46 | it('should allow string as field item', createTest(['broken'])); 47 | it('should allow json path array as field item', createTest([['broken']])); 48 | }); 49 | 50 | describe('mainFields', () => { 51 | const createTest = (mainFields) => { 52 | const resolver = new ResolverFactory({ mainFields }); 53 | assert.match( 54 | normalizePath(resolver.sync(fixtureDir, '../..').path), 55 | /\/lib\/index\.js$/, 56 | ); 57 | }; 58 | it("should use `'main'` as default", createTest(undefined)); 59 | it('should allow field string', createTest('main')); 60 | it('should allow field array', createTest(['main'])); 61 | }); 62 | }); 63 | -------------------------------------------------------------------------------- /examples/many.rs: -------------------------------------------------------------------------------- 1 | use std::{env, fs}; 2 | 3 | use rayon::prelude::*; 4 | 5 | use oxc_resolver::{ResolveOptions, Resolver}; 6 | 7 | fn main() { 8 | let cwd = env::current_dir().expect("Failed to get current directory"); 9 | let node_modules = cwd.join("node_modules"); 10 | 11 | if !node_modules.exists() { 12 | eprintln!("node_modules directory not found at {}", node_modules.display()); 13 | return; 14 | } 15 | 16 | // Collect all package names 17 | let mut packages = Vec::new(); 18 | 19 | let entries = fs::read_dir(&node_modules).expect("Failed to read node_modules directory"); 20 | 21 | for entry in entries.filter_map(Result::ok) { 22 | let path = entry.path(); 23 | if !path.is_dir() { 24 | continue; 25 | } 26 | 27 | let dir_name = path.file_name().unwrap().to_string_lossy(); 28 | 29 | // Skip dot directories 30 | if dir_name.starts_with('.') { 31 | continue; 32 | } 33 | 34 | if dir_name.starts_with('@') { 35 | // Skip @types packages 36 | if dir_name == "@types" { 37 | continue; 38 | } 39 | // Scoped package - read subdirectories 40 | if let Ok(scope_entries) = fs::read_dir(&path) { 41 | for scope_entry in scope_entries.filter_map(Result::ok) { 42 | let scope_path = scope_entry.path(); 43 | if scope_path.is_dir() { 44 | let package_name = scope_path.file_name().unwrap().to_string_lossy(); 45 | packages.push(format!("{dir_name}/{package_name}")); 46 | } 47 | } 48 | } 49 | } else { 50 | // Regular package 51 | packages.push(dir_name.to_string()); 52 | } 53 | } 54 | 55 | let options = ResolveOptions { 56 | condition_names: vec!["node".into(), "import".into()], 57 | ..ResolveOptions::default() 58 | }; 59 | let resolver = Resolver::new(options); 60 | 61 | packages.par_iter().for_each(|package| { 62 | if let Err(err) = resolver.resolve(&cwd, package) { 63 | eprintln!("{package}: {err}"); 64 | } 65 | }); 66 | } 67 | -------------------------------------------------------------------------------- /.github/workflows/codecov.yml: -------------------------------------------------------------------------------- 1 | name: Code Coverage # Run cargo-llvm-cov and upload to codecov.io 2 | 3 | permissions: {} 4 | 5 | on: 6 | workflow_dispatch: 7 | pull_request: 8 | types: 9 | - opened 10 | - synchronize 11 | paths: 12 | - "src/**/*.rs" 13 | - "Cargo.lock" 14 | push: 15 | branches: 16 | - main 17 | paths: 18 | - "src/**/*.rs" 19 | - "Cargo.lock" 20 | 21 | concurrency: 22 | group: ${{ github.workflow }}-${{ github.ref }} 23 | cancel-in-progress: true 24 | 25 | jobs: 26 | coverage: 27 | name: Code Coverage 28 | runs-on: ubuntu-latest 29 | steps: 30 | - name: Checkout 31 | uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 32 | 33 | - uses: ./.github/actions/pnpm 34 | 35 | - uses: oxc-project/setup-rust@ecabb7322a2ba5aeedb3612d2a40b86a85cee235 # v1.0.11 36 | with: 37 | cache-key: codecov 38 | save-cache: ${{ github.ref_name == 'main' }} 39 | tools: cargo-llvm-cov 40 | components: llvm-tools-preview 41 | 42 | - run: cargo llvm-cov --lcov --output-path lcov.info 43 | 44 | - name: Upload Artifact 45 | uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 46 | with: 47 | name: codecov 48 | path: lcov.info 49 | 50 | # codecov often fails, use another workflow for retry 51 | upload-codecov: 52 | name: Upload coverage file 53 | runs-on: ubuntu-latest 54 | needs: coverage 55 | # Check if the event is not triggered by a fork by checking whether CODECOV_TOKEN is set 56 | env: 57 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 58 | steps: 59 | - name: Checkout 60 | if: env.CODECOV_TOKEN 61 | uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 62 | 63 | - name: Download coverage file 64 | if: env.CODECOV_TOKEN 65 | uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 66 | with: 67 | name: codecov 68 | 69 | - name: Upload to codecov.io 70 | if: env.CODECOV_TOKEN 71 | uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 72 | with: 73 | token: ${{ secrets.CODECOV_TOKEN }} 74 | fail_ci_if_error: true 75 | files: lcov.info 76 | -------------------------------------------------------------------------------- /src/context.rs: -------------------------------------------------------------------------------- 1 | use std::path::{Path, PathBuf}; 2 | 3 | use crate::error::ResolveError; 4 | 5 | #[derive(Debug, Default, Clone)] 6 | pub struct ResolveContext { 7 | pub fully_specified: bool, 8 | 9 | pub query: Option, 10 | 11 | pub fragment: Option, 12 | 13 | /// Files that was found on file system. 14 | pub file_dependencies: Option>, 15 | 16 | /// Dependencies that was not found on file system. 17 | pub missing_dependencies: Option>, 18 | 19 | /// The current resolving alias for bailing recursion alias. 20 | pub resolving_alias: Option, 21 | 22 | /// For avoiding infinite recursion, which will cause stack overflow. 23 | depth: u8, 24 | } 25 | 26 | impl ResolveContext { 27 | pub fn with_fully_specified(&mut self, yes: bool) { 28 | self.fully_specified = yes; 29 | } 30 | 31 | pub fn with_query_fragment(&mut self, query: Option<&str>, fragment: Option<&str>) { 32 | if let Some(query) = query { 33 | self.query.replace(query.to_string()); 34 | } 35 | if let Some(fragment) = fragment { 36 | self.fragment.replace(fragment.to_string()); 37 | } 38 | } 39 | 40 | pub fn init_file_dependencies(&mut self) { 41 | self.file_dependencies.replace(vec![]); 42 | self.missing_dependencies.replace(vec![]); 43 | } 44 | 45 | pub fn add_file_dependency(&mut self, dep: &Path) { 46 | if let Some(deps) = &mut self.file_dependencies { 47 | deps.push(dep.to_path_buf()); 48 | } 49 | } 50 | 51 | pub fn add_missing_dependency(&mut self, dep: &Path) { 52 | if let Some(deps) = &mut self.missing_dependencies { 53 | deps.push(dep.to_path_buf()); 54 | } 55 | } 56 | 57 | pub fn with_resolving_alias(&mut self, alias: String) { 58 | self.resolving_alias = Some(alias); 59 | } 60 | 61 | /// Increases the context's depth in order to detect recursion. 62 | /// 63 | /// ### Errors 64 | /// 65 | /// * [ResolveError::Recursion] 66 | pub fn test_for_infinite_recursion(&mut self) -> Result<(), ResolveError> { 67 | self.depth += 1; 68 | // 64 should be more than enough for detecting infinite recursion. 69 | if self.depth > 64 { 70 | return Err(ResolveError::Recursion); 71 | } 72 | Ok(()) 73 | } 74 | } 75 | --------------------------------------------------------------------------------