From 6fb15280bcef1c1690ef18bc86fa3d03f7e73fa4 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Wed, 27 Mar 2024 00:04:48 +0900 Subject: [PATCH] fix(vite-node): fix `isValidNodeImport` to check `"type": "module"` first (#5416) --- packages/vite-node/src/externalize.ts | 6 +- pnpm-lock.yaml | 309 +++++++++++++++++--------- test/vite-node/deps/dep1/esm/index.js | 4 + test/vite-node/deps/dep1/package.json | 5 + test/vite-node/deps/dep2/index.js | 1 + test/vite-node/deps/dep2/package.json | 8 + test/vite-node/package.json | 2 + test/vite-node/test/external.test.ts | 12 + 8 files changed, 244 insertions(+), 103 deletions(-) create mode 100644 test/vite-node/deps/dep1/esm/index.js create mode 100644 test/vite-node/deps/dep1/package.json create mode 100644 test/vite-node/deps/dep2/index.js create mode 100644 test/vite-node/deps/dep2/package.json create mode 100644 test/vite-node/test/external.test.ts diff --git a/packages/vite-node/src/externalize.ts b/packages/vite-node/src/externalize.ts index e306bbba9a22..0600ed798eb7 100644 --- a/packages/vite-node/src/externalize.ts +++ b/packages/vite-node/src/externalize.ts @@ -61,9 +61,6 @@ async function isValidNodeImport(id: string) { if (extension !== '.js') return false - if (/\.(\w+-)?esm?(-\w+)?\.js$|\/(esm?)\//.test(id)) - return false - id = id.replace('file:///', '') const package_ = await findNearestPackageData(dirname(id)) @@ -71,6 +68,9 @@ async function isValidNodeImport(id: string) { if (package_.type === 'module') return true + if (/\.(\w+-)?esm?(-\w+)?\.js$|\/(esm?)\//.test(id)) + return false + const code = await fsp.readFile(id, 'utf8').catch(() => '') return !ESM_SYNTAX_RE.test(code) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index daffe20a880c..47e6c794fb4b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2072,6 +2072,12 @@ importers: '@types/inquirer': specifier: ^9.0.3 version: 9.0.3 + '@vitest/test-dep1': + specifier: file:./deps/dep1 + version: file:test/vite-node/deps/dep1 + '@vitest/test-dep2': + specifier: file:./deps/dep2 + version: file:test/vite-node/deps/dep2(@vitest/test-dep1@undefined) execa: specifier: ^6.1.0 version: 6.1.0 @@ -2561,7 +2567,7 @@ packages: resolution: {integrity: sha512-QkBXwGgaoC2GtGZRoma6kv7Szfv06khvhFav67ZExau2RaXzy8MpHSMO2PNoP2XtmQphJQRHFfg77Bq731Yizw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.6 + '@babel/types': 7.24.0 dev: true /@babel/helper-compilation-targets@7.22.15: @@ -2656,7 +2662,22 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-compilation-targets': 7.22.15 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 + debug: 4.3.4(supports-color@8.1.1) + lodash.debounce: 4.0.8 + resolve: 1.22.8 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/helper-define-polyfill-provider@0.6.1(@babel/core@7.23.3): + resolution: {integrity: sha512-o7SDgTJuvx5vLKD6SFvkydkSMBvahDKGiNJzG22IZYXhiqoe9efY7zocICBgzHV4IRg5wdgl2nEL/tulKIEIbA==} + peerDependencies: + '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 + dependencies: + '@babel/core': 7.23.3 + '@babel/helper-compilation-targets': 7.22.15 + '@babel/helper-plugin-utils': 7.24.0 debug: 4.3.4(supports-color@8.1.1) lodash.debounce: 4.0.8 resolve: 1.22.8 @@ -2715,6 +2736,13 @@ packages: '@babel/types': 7.23.3 dev: false + /@babel/helper-module-imports@7.24.3: + resolution: {integrity: sha512-viKb0F9f2s0BCS22QSF308z/+1YWKV/76mwt61NBzS5izMzDPwdq1pTrzf+Li3npBWX9KdQbkeCt1jSAM7lZqg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.24.0 + dev: true + /@babel/helper-module-transforms@7.23.3(@babel/core@7.12.9): resolution: {integrity: sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==} engines: {node: '>=6.9.0'} @@ -2757,6 +2785,11 @@ packages: resolution: {integrity: sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==} engines: {node: '>=6.9.0'} + /@babel/helper-plugin-utils@7.24.0: + resolution: {integrity: sha512-9cUznXMG0+FxRuJfvL82QlTqIzhVW9sL0KjMPHhAOOvpQGL8QtdxnBKILjBqxlHyliz0yCa1G903ZXI/FuHy2w==} + engines: {node: '>=6.9.0'} + dev: true + /@babel/helper-remap-async-to-generator@7.18.9(@babel/core@7.23.3): resolution: {integrity: sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA==} engines: {node: '>=6.9.0'} @@ -2854,7 +2887,7 @@ packages: dependencies: '@babel/helper-function-name': 7.23.0 '@babel/template': 7.22.15 - '@babel/types': 7.23.6 + '@babel/types': 7.24.0 dev: true /@babel/helpers@7.23.2: @@ -2915,7 +2948,7 @@ packages: '@babel/core': ^7.0.0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.18.9(@babel/core@7.23.3): @@ -2937,7 +2970,7 @@ packages: '@babel/core': ^7.13.0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-skip-transparent-expression-wrappers': 7.22.5 '@babel/plugin-transform-optional-chaining': 7.23.0(@babel/core@7.23.3) dev: true @@ -3178,7 +3211,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-syntax-class-properties@7.12.13(@babel/core@7.23.3): @@ -3265,7 +3298,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-syntax-import-attributes@7.22.5(@babel/core@7.23.3): @@ -3275,7 +3308,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-syntax-import-meta@7.10.4(@babel/core@7.23.3): @@ -3284,7 +3317,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-syntax-json-strings@7.8.3(@babel/core@7.23.3): @@ -3436,7 +3469,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-regexp-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-arrow-functions@7.18.6(@babel/core@7.23.3): @@ -3456,7 +3489,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-async-generator-functions@7.23.2(@babel/core@7.23.3): @@ -3467,7 +3500,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-remap-async-to-generator': 7.22.20(@babel/core@7.23.3) '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.23.3) dev: true @@ -3493,8 +3526,8 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-module-imports': 7.22.15 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-module-imports': 7.24.3 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-remap-async-to-generator': 7.22.20(@babel/core@7.23.3) dev: true @@ -3515,7 +3548,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-block-scoping@7.18.9(@babel/core@7.23.3): @@ -3535,7 +3568,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-class-properties@7.22.5(@babel/core@7.23.3): @@ -3546,7 +3579,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-class-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-class-static-block@7.22.11(@babel/core@7.23.3): @@ -3557,7 +3590,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-class-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-class-static-block': 7.14.5(@babel/core@7.23.3) dev: true @@ -3590,7 +3623,7 @@ packages: '@babel/helper-environment-visitor': 7.22.20 '@babel/helper-function-name': 7.23.0 '@babel/helper-optimise-call-expression': 7.22.5 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-replace-supers': 7.22.20(@babel/core@7.23.3) '@babel/helper-split-export-declaration': 7.22.6 globals: 11.12.0 @@ -3613,7 +3646,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/template': 7.22.15 dev: true @@ -3634,7 +3667,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-dotall-regex@7.18.6(@babel/core@7.23.3): @@ -3656,7 +3689,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-regexp-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-duplicate-keys@7.18.9(@babel/core@7.23.3): @@ -3676,7 +3709,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-dynamic-import@7.22.11(@babel/core@7.23.3): @@ -3686,7 +3719,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-dynamic-import': 7.8.3(@babel/core@7.23.3) dev: true @@ -3709,7 +3742,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-builder-binary-assignment-operator-visitor': 7.22.15 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-export-namespace-from@7.22.11(@babel/core@7.23.3): @@ -3719,7 +3752,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-export-namespace-from': 7.8.3(@babel/core@7.23.3) dev: true @@ -3751,7 +3784,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-function-name@7.18.9(@babel/core@7.23.3): @@ -3775,7 +3808,7 @@ packages: '@babel/core': 7.23.3 '@babel/helper-compilation-targets': 7.22.15 '@babel/helper-function-name': 7.23.0 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-json-strings@7.22.11(@babel/core@7.23.3): @@ -3785,7 +3818,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-json-strings': 7.8.3(@babel/core@7.23.3) dev: true @@ -3806,7 +3839,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-logical-assignment-operators@7.22.11(@babel/core@7.23.3): @@ -3816,7 +3849,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/core@7.23.3) dev: true @@ -3837,7 +3870,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-modules-amd@7.18.6(@babel/core@7.23.3): @@ -3860,7 +3893,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-module-transforms': 7.23.3(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-modules-commonjs@7.23.0(@babel/core@7.23.3): @@ -3898,7 +3931,7 @@ packages: '@babel/core': 7.23.3 '@babel/helper-hoist-variables': 7.22.5 '@babel/helper-module-transforms': 7.23.3(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-validator-identifier': 7.22.20 dev: true @@ -3921,7 +3954,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-module-transforms': 7.23.3(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-named-capturing-groups-regex@7.18.6(@babel/core@7.23.3): @@ -3943,7 +3976,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-regexp-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-new-target@7.18.6(@babel/core@7.23.3): @@ -3963,7 +3996,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-nullish-coalescing-operator@7.22.11(@babel/core@7.23.3): @@ -3973,7 +4006,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.23.3) dev: true @@ -3984,7 +4017,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/core@7.23.3) dev: true @@ -3997,7 +4030,7 @@ packages: '@babel/compat-data': 7.23.2 '@babel/core': 7.23.3 '@babel/helper-compilation-targets': 7.22.15 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.23.3) '@babel/plugin-transform-parameters': 7.22.15(@babel/core@7.23.3) dev: true @@ -4020,7 +4053,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-replace-supers': 7.22.20(@babel/core@7.23.3) dev: true @@ -4031,7 +4064,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.23.3) dev: true @@ -4042,7 +4075,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-skip-transparent-expression-wrappers': 7.22.5 '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.23.3) dev: true @@ -4074,7 +4107,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-private-methods@7.22.5(@babel/core@7.23.3): @@ -4085,7 +4118,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-class-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-private-property-in-object@7.22.11(@babel/core@7.23.3): @@ -4097,7 +4130,7 @@ packages: '@babel/core': 7.23.3 '@babel/helper-annotate-as-pure': 7.22.5 '@babel/helper-create-class-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/core@7.23.3) dev: true @@ -4118,7 +4151,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-react-display-name@7.18.6(@babel/core@7.23.3): @@ -4248,7 +4281,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 regenerator-transform: 0.15.2 dev: true @@ -4269,7 +4302,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-shorthand-properties@7.18.6(@babel/core@7.23.3): @@ -4289,7 +4322,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-spread@7.18.9(@babel/core@7.23.3): @@ -4310,7 +4343,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-skip-transparent-expression-wrappers': 7.22.5 dev: true @@ -4331,7 +4364,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-template-literals@7.18.9(@babel/core@7.23.3): @@ -4351,7 +4384,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-typeof-symbol@7.18.9(@babel/core@7.23.3): @@ -4371,7 +4404,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-typescript@7.22.15(@babel/core@7.23.3): @@ -4417,7 +4450,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-unicode-property-regex@7.22.5(@babel/core@7.23.3): @@ -4428,7 +4461,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-regexp-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-unicode-regex@7.18.6(@babel/core@7.23.3): @@ -4450,7 +4483,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-regexp-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/plugin-transform-unicode-sets-regex@7.22.5(@babel/core@7.23.3): @@ -4461,7 +4494,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-create-regexp-features-plugin': 7.22.15(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 dev: true /@babel/preset-env@7.18.10(@babel/core@7.23.3): @@ -4559,7 +4592,7 @@ packages: '@babel/compat-data': 7.23.2 '@babel/core': 7.23.3 '@babel/helper-compilation-targets': 7.22.15 - '@babel/helper-plugin-utils': 7.22.5 + '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-validator-option': 7.22.15 '@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression': 7.22.15(@babel/core@7.23.3) '@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining': 7.22.15(@babel/core@7.23.3) @@ -4631,11 +4664,11 @@ packages: '@babel/plugin-transform-unicode-regex': 7.22.5(@babel/core@7.23.3) '@babel/plugin-transform-unicode-sets-regex': 7.22.5(@babel/core@7.23.3) '@babel/preset-modules': 0.1.6-no-external-plugins(@babel/core@7.23.3) - '@babel/types': 7.23.6 - babel-plugin-polyfill-corejs2: 0.4.6(@babel/core@7.23.3) + '@babel/types': 7.24.0 + babel-plugin-polyfill-corejs2: 0.4.10(@babel/core@7.23.3) babel-plugin-polyfill-corejs3: 0.8.5(@babel/core@7.23.3) babel-plugin-polyfill-regenerator: 0.5.3(@babel/core@7.23.3) - core-js-compat: 3.35.1 + core-js-compat: 3.36.1 semver: 6.3.1 transitivePeerDependencies: - supports-color @@ -4672,8 +4705,8 @@ packages: '@babel/core': ^7.0.0-0 || ^8.0.0-0 <8.0.0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 - '@babel/types': 7.23.6 + '@babel/helper-plugin-utils': 7.24.0 + '@babel/types': 7.24.0 esutils: 2.0.3 dev: true @@ -4798,6 +4831,15 @@ packages: '@babel/helper-validator-identifier': 7.22.20 to-fast-properties: 2.0.0 + /@babel/types@7.24.0: + resolution: {integrity: sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-string-parser': 7.23.4 + '@babel/helper-validator-identifier': 7.22.20 + to-fast-properties: 2.0.0 + dev: true + /@base2/pretty-print-object@1.0.1: resolution: {integrity: sha512-4iri8i1AqYHJE2DstZYkyEprg6Pq6sKx3xn5FpySk9sNhH7qN2LLlHJCfDTZRILNwQNPD7mATWM0TBui7uC1pA==} dev: true @@ -5813,7 +5855,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 chalk: 4.1.2 jest-message-util: 27.5.1 jest-util: 27.5.1 @@ -5834,7 +5876,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.8.1 @@ -5871,7 +5913,7 @@ packages: dependencies: '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 jest-mock: 27.5.1 dev: true @@ -5888,7 +5930,7 @@ packages: dependencies: '@jest/types': 27.5.1 '@sinonjs/fake-timers': 8.1.0 - '@types/node': 20.11.27 + '@types/node': 20.11.30 jest-message-util: 27.5.1 jest-mock: 27.5.1 jest-util: 27.5.1 @@ -5917,7 +5959,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -6048,7 +6090,7 @@ packages: dependencies: '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 20.11.27 + '@types/node': 20.11.30 '@types/yargs': 16.0.7 chalk: 4.1.2 dev: true @@ -7084,7 +7126,7 @@ packages: optional: true dependencies: '@babel/core': 7.23.3 - '@babel/helper-module-imports': 7.22.15 + '@babel/helper-module-imports': 7.24.3 '@rollup/pluginutils': 3.1.0(rollup@4.9.6) rollup: 4.9.6 dev: true @@ -9394,7 +9436,7 @@ packages: resolution: {integrity: sha512-N7UDG0/xiPQa2D/XrVJXjkWbpqHCd2sBaB32ggRF2l83RhPfamgKGF8gwwqyksS95qUS5ZYF9aF+lLPRlwI2UA==} dependencies: '@types/connect': 3.4.37 - '@types/node': 20.11.27 + '@types/node': 20.11.30 dev: true /@types/braces@3.0.1: @@ -9415,7 +9457,7 @@ packages: /@types/connect@3.4.37: resolution: {integrity: sha512-zBUSRqkfZ59OcwXon4HVxhx5oWCJmc0OtBTK05M+p0dYjgN6iTwIL2T/WbsQZrEsdnwaF9cWQ+azOnpPvIqY3Q==} dependencies: - '@types/node': 20.11.27 + '@types/node': 20.11.30 dev: true /@types/cookie@0.4.1: @@ -9482,7 +9524,7 @@ packages: /@types/express-serve-static-core@4.17.39: resolution: {integrity: sha512-BiEUfAiGCOllomsRAZOiMFP7LAnrifHpt56pc4Z7l9K6ACyN06Ns1JLMBxwkfLOjJRlSf06NwWsT7yzfpaVpyQ==} dependencies: - '@types/node': 20.11.27 + '@types/node': 20.11.30 '@types/qs': 6.9.9 '@types/range-parser': 1.2.6 '@types/send': 0.17.3 @@ -9543,7 +9585,7 @@ packages: /@types/graceful-fs@4.1.8: resolution: {integrity: sha512-NhRH7YzWq8WiNKVavKPBmtLYZHxNY19Hh+az28O/phfp68CF45pMFud+ZzJ8ewnxnC5smIdF3dqFeiSUQ5I+pw==} dependencies: - '@types/node': 20.11.27 + '@types/node': 20.11.30 dev: true /@types/hast@2.3.4: @@ -9703,7 +9745,7 @@ packages: /@types/node-fetch@2.6.7: resolution: {integrity: sha512-lX17GZVpJ/fuCjguZ5b3TjEbSENxmEk1B2z02yoXSK9WMEWRivhdSY73wWMn6bpcCDAOh6qAdktpKHIlkDk2lg==} dependencies: - '@types/node': 20.11.27 + '@types/node': 20.11.30 form-data: 4.0.0 dev: true @@ -9730,8 +9772,8 @@ packages: undici-types: 5.26.5 dev: true - /@types/node@20.11.27: - resolution: {integrity: sha512-qyUZfMnCg1KEz57r7pzFtSGt49f6RPkPBis3Vo4PbS7roQEDn22hiHzl/Lo1q4i4hDEgBJmBF/NTNg2XR0HbFg==} + /@types/node@20.11.30: + resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==} dependencies: undici-types: 5.26.5 dev: true @@ -9895,7 +9937,7 @@ packages: /@types/resolve@1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 20.11.27 + '@types/node': 20.11.30 dev: true /@types/resolve@1.20.2: @@ -9913,7 +9955,7 @@ packages: resolution: {integrity: sha512-/7fKxvKUoETxjFUsuFlPB9YndePpxxRAOfGC/yJdc9kTjTeP5kRCTzfnE8kPUKCeyiyIZu0YQ76s50hCedI1ug==} dependencies: '@types/mime': 1.3.4 - '@types/node': 20.11.27 + '@types/node': 20.11.30 dev: true /@types/serve-static@1.15.4: @@ -9921,7 +9963,7 @@ packages: dependencies: '@types/http-errors': 2.0.3 '@types/mime': 3.0.3 - '@types/node': 20.11.27 + '@types/node': 20.11.30 dev: true /@types/set-cookie-parser@2.4.2: @@ -12315,7 +12357,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@babel/template': 7.22.15 - '@babel/types': 7.23.6 + '@babel/types': 7.24.0 '@types/babel__core': 7.20.5 '@types/babel__traverse': 7.20.3 dev: true @@ -12354,14 +12396,14 @@ packages: - supports-color dev: true - /babel-plugin-polyfill-corejs2@0.4.6(@babel/core@7.23.3): - resolution: {integrity: sha512-jhHiWVZIlnPbEUKSSNb9YoWcQGdlTLq7z1GHL4AjFxaoOUMuuEVJ+Y4pAaQUGOGk93YsVCKPbqbfw3m0SM6H8Q==} + /babel-plugin-polyfill-corejs2@0.4.10(@babel/core@7.23.3): + resolution: {integrity: sha512-rpIuu//y5OX6jVU+a5BCn1R5RSZYWAl2Nar76iwaOdycqb6JPxediskWFMMl7stfwNJR4b7eiQvh5fB5TEQJTQ==} peerDependencies: '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 dependencies: '@babel/compat-data': 7.23.2 '@babel/core': 7.23.3 - '@babel/helper-define-polyfill-provider': 0.4.3(@babel/core@7.23.3) + '@babel/helper-define-polyfill-provider': 0.6.1(@babel/core@7.23.3) semver: 6.3.1 transitivePeerDependencies: - supports-color @@ -12398,7 +12440,7 @@ packages: dependencies: '@babel/core': 7.23.3 '@babel/helper-define-polyfill-provider': 0.4.3(@babel/core@7.23.3) - core-js-compat: 3.35.1 + core-js-compat: 3.36.1 transitivePeerDependencies: - supports-color dev: true @@ -12789,6 +12831,17 @@ packages: update-browserslist-db: 1.0.13(browserslist@4.22.3) dev: true + /browserslist@4.23.0: + resolution: {integrity: sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + dependencies: + caniuse-lite: 1.0.30001600 + electron-to-chromium: 1.4.715 + node-releases: 2.0.14 + update-browserslist-db: 1.0.13(browserslist@4.23.0) + dev: true + /bser@2.1.1: resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} dependencies: @@ -13079,6 +13132,10 @@ packages: resolution: {integrity: sha512-yr2BWR1yLXQ8fMpdS/4ZZXpseBgE7o4g41x3a6AJOqZuOi+iE/WdJYAuZ6Y95i4Ohd2Y+9MzIWRR+uGABH4s3Q==} dev: true + /caniuse-lite@1.0.30001600: + resolution: {integrity: sha512-+2S9/2JFhYmYaDpZvo0lKkfvuKIglrx68MwOBqMGHhQsNkLjB5xtc/TGoEPs+MxjSyN/72qer2g97nzR641mOQ==} + dev: true + /capture-exit@2.0.0: resolution: {integrity: sha512-PiT/hQmTonHhl/HFGN+Lx3JJUznrVYJ3+AQsnthneZbvW7x+f08Tk7yLJTLEOUvBTbduLeeBkxEaYXUOUrRq6g==} engines: {node: 6.* || 8.* || >= 10.*} @@ -13256,6 +13313,23 @@ packages: fsevents: 2.3.3 dev: true + /chokidar@3.6.0: + resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} + engines: {node: '>= 8.10.0'} + requiresBuild: true + dependencies: + anymatch: 3.1.3 + braces: 3.0.2 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.3 + dev: true + optional: true + /chownr@1.1.4: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} dev: true @@ -13752,6 +13826,12 @@ packages: browserslist: 4.22.3 dev: true + /core-js-compat@3.36.1: + resolution: {integrity: sha512-Dk997v9ZCt3X/npqzyGdTlq6t7lDBhZwGvV94PKzDArjp7BTRm7WlDAXYd/OWdeFHO8OChQYRJNJvUCqCbrtKA==} + dependencies: + browserslist: 4.23.0 + dev: true + /core-js-pure@3.25.0: resolution: {integrity: sha512-IeHpLwk3uoci37yoI2Laty59+YqH9x5uR65/yiA0ARAJrTrN4YU0rmauLWfvqOuk77SlNJXj2rM6oT/dBD87+A==} requiresBuild: true @@ -14895,6 +14975,10 @@ packages: resolution: {integrity: sha512-AFg4wDHSOk5F+zA8aR+SVIOabu7m0e7BiJnigCvPXzIGy731XENw/lmNxTySpVFtkFEy+eyt4oHhh5FF3NjQNw==} dev: true + /electron-to-chromium@1.4.715: + resolution: {integrity: sha512-XzWNH4ZSa9BwVUQSDorPWAUQ5WGuYz7zJUNpNif40zFCiCl20t8zgylmreNmn26h5kiyw2lg7RfTmeMBsDklqg==} + dev: true + /elliptic@6.5.4: resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} dependencies: @@ -18941,7 +19025,7 @@ packages: '@jest/environment': 27.5.1 '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -19076,7 +19160,7 @@ packages: '@jest/environment': 27.5.1 '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 jest-mock: 27.5.1 jest-util: 27.5.1 jsdom: 16.7.0 @@ -19094,7 +19178,7 @@ packages: '@jest/environment': 27.5.1 '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 jest-mock: 27.5.1 jest-util: 27.5.1 dev: true @@ -19138,7 +19222,7 @@ packages: dependencies: '@jest/types': 27.5.1 '@types/graceful-fs': 4.1.8 - '@types/node': 20.11.27 + '@types/node': 20.11.30 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -19178,7 +19262,7 @@ packages: '@jest/source-map': 27.5.1 '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 chalk: 4.1.2 co: 4.6.0 expect: 27.5.1 @@ -19258,7 +19342,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 dev: true /jest-pnp-resolver@1.2.3(jest-resolve@27.5.1): @@ -19319,7 +19403,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 chalk: 4.1.2 emittery: 0.8.1 graceful-fs: 4.2.11 @@ -19384,7 +19468,7 @@ packages: resolution: {integrity: sha512-jZCyo6iIxO1aqUxpuBlwTDMkzOAJS4a3eYz3YzgxxVQFwLeSA7Jfq5cbqCY+JLvTDrWirgusI/0KwxKMgrdf7w==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: - '@types/node': 20.11.27 + '@types/node': 20.11.30 graceful-fs: 4.2.11 dev: true @@ -19396,7 +19480,7 @@ packages: '@babel/generator': 7.23.3 '@babel/plugin-syntax-typescript': 7.23.3(@babel/core@7.23.3) '@babel/traverse': 7.23.3 - '@babel/types': 7.23.6 + '@babel/types': 7.24.0 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 '@types/babel__traverse': 7.20.3 @@ -19435,7 +19519,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -19472,7 +19556,7 @@ packages: dependencies: '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 20.11.27 + '@types/node': 20.11.30 ansi-escapes: 4.3.2 chalk: 4.1.2 jest-util: 27.5.1 @@ -26294,6 +26378,17 @@ packages: picocolors: 1.0.0 dev: true + /update-browserslist-db@1.0.13(browserslist@4.23.0): + resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + dependencies: + browserslist: 4.23.0 + escalade: 3.1.1 + picocolors: 1.0.0 + dev: true + /uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: @@ -26947,7 +27042,7 @@ packages: graceful-fs: 4.2.11 neo-async: 2.6.2 optionalDependencies: - chokidar: 3.5.3 + chokidar: 3.6.0 watchpack-chokidar2: 2.0.1 transitivePeerDependencies: - supports-color @@ -27305,7 +27400,7 @@ packages: '@webassemblyjs/wasm-parser': 1.11.6 acorn: 8.11.3 acorn-import-assertions: 1.9.0(acorn@8.11.3) - browserslist: 4.22.3 + browserslist: 4.23.0 chrome-trace-event: 1.0.3 enhanced-resolve: 5.15.0 es-module-lexer: 1.3.1 @@ -27595,7 +27690,6 @@ packages: /workbox-google-analytics@7.0.0: resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==} - deprecated: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained dependencies: workbox-background-sync: 7.0.0 workbox-core: 7.0.0 @@ -27991,3 +28085,18 @@ packages: resolution: {directory: test/optimize-deps/dep-url, type: directory} name: '@vitest/test-deps-url' dev: true + + file:test/vite-node/deps/dep1: + resolution: {directory: test/vite-node/deps/dep1, type: directory} + name: '@vitest/test-dep1' + dev: true + + file:test/vite-node/deps/dep2(@vitest/test-dep1@undefined): + resolution: {directory: test/vite-node/deps/dep2, type: directory} + id: file:test/vite-node/deps/dep2 + name: '@vitest/test-dep2' + peerDependencies: + '@vitest/test-dep1': '*' + dependencies: + '@vitest/test-dep1': file:test/vite-node/deps/dep1 + dev: true diff --git a/test/vite-node/deps/dep1/esm/index.js b/test/vite-node/deps/dep1/esm/index.js new file mode 100644 index 000000000000..664e0bad5443 --- /dev/null +++ b/test/vite-node/deps/dep1/esm/index.js @@ -0,0 +1,4 @@ +// esm/index.js was detected as isValidNodeImport(id) = false +// event if package.json has type = module, +// which causes dual package hazard when other external esm import esm/index.js. +export const data = {} diff --git a/test/vite-node/deps/dep1/package.json b/test/vite-node/deps/dep1/package.json new file mode 100644 index 000000000000..a438d0768ddd --- /dev/null +++ b/test/vite-node/deps/dep1/package.json @@ -0,0 +1,5 @@ +{ + "name": "@vitest/test-dep1", + "type": "module", + "exports": "./esm/index.js" +} diff --git a/test/vite-node/deps/dep2/index.js b/test/vite-node/deps/dep2/index.js new file mode 100644 index 000000000000..23d22007ced1 --- /dev/null +++ b/test/vite-node/deps/dep2/index.js @@ -0,0 +1 @@ +export { data } from '@vitest/test-dep1' diff --git a/test/vite-node/deps/dep2/package.json b/test/vite-node/deps/dep2/package.json new file mode 100644 index 000000000000..81049572392f --- /dev/null +++ b/test/vite-node/deps/dep2/package.json @@ -0,0 +1,8 @@ +{ + "name": "@vitest/test-dep2", + "type": "module", + "exports": "./index.js", + "peerDependencies": { + "@vitest/test-dep1": "*" + } +} diff --git a/test/vite-node/package.json b/test/vite-node/package.json index 6bb382c179f7..c655543de30a 100644 --- a/test/vite-node/package.json +++ b/test/vite-node/package.json @@ -11,6 +11,8 @@ }, "devDependencies": { "@types/inquirer": "^9.0.3", + "@vitest/test-dep1": "file:./deps/dep1", + "@vitest/test-dep2": "file:./deps/dep2", "execa": "^6.1.0", "inquirer": "^9.2.7", "vite-node": "workspace:*", diff --git a/test/vite-node/test/external.test.ts b/test/vite-node/test/external.test.ts new file mode 100644 index 000000000000..f751e594d877 --- /dev/null +++ b/test/vite-node/test/external.test.ts @@ -0,0 +1,12 @@ +import { expect, test } from 'vitest' + +// @ts-expect-error no ts +import * as dep1 from '@vitest/test-dep1' + +// @ts-expect-error no ts +import * as dep2 from '@vitest/test-dep2' + +test('no dual package hazard by externalizing esm deps by default', async () => { + dep1.data.hello = 'world' + expect(dep2.data.hello).toBe('world') +})