Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitest >= 0.34.3 - Module resolution broken ERR_UNKNOWN_FILE_EXTENSION #4068

Closed
6 tasks done
haikyuu opened this issue Sep 4, 2023 · 6 comments · Fixed by #4080
Closed
6 tasks done

Vitest >= 0.34.3 - Module resolution broken ERR_UNKNOWN_FILE_EXTENSION #4068

haikyuu opened this issue Sep 4, 2023 · 6 comments · Fixed by #4080

Comments

@haikyuu
Copy link
Contributor

haikyuu commented Sep 4, 2023

Describe the bug

Vitest no longer resolves files correctly. This was introduced in Vitest 0.34.3 most probably by this PR


 ❯ test.test.imba (0)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  test.test.imba [ test.test.imba ]
TypeError: Unknown file extension ".imba" for /wsp/imba/packages/imba/src/utils/std/std.imba
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_UNKNOWN_FILE_EXTENSION' }

Reproduction

Run imba test to reproduce.
https://stackblitz.com/edit/vitejs-vite-fbhutt?file=add.test.imba&terminal=dev

Also note that it works in vitest 0.34.2

System Info

*

Used Package Manager

npm

Validations

@stackblitz
Copy link

stackblitz bot commented Sep 4, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@haikyuu haikyuu changed the title Module resolution broken ERR_UNKNOWN_FILE_EXTENSION Module resolution broken in vitest >= 0.34.3 ERR_UNKNOWN_FILE_EXTENSION Sep 4, 2023
@haikyuu haikyuu changed the title Module resolution broken in vitest >= 0.34.3 ERR_UNKNOWN_FILE_EXTENSION Vitest >= 0.34.3 - Module resolution broken ERR_UNKNOWN_FILE_EXTENSION Sep 4, 2023
@haikyuu
Copy link
Contributor Author

haikyuu commented Sep 4, 2023

Here is the resolved config

vite:config bundled config file loaded in 12.03ms +0ms
  vite:config using resolved config: {
  vite:config   client: {
  vite:config     worker: { plugins: [Array] },
  vite:config     envPrefix: [ 'VITE_', 'IMBA_', 'OP_', 'TEST_', 'VITEST_' ],
  vite:config     plugins: [ [Array], [Object] ],
  vite:config     resolve: { conditions: [Array], extensions: [Array], dedupe: [Array] },
  vite:config     build: {
  vite:config       manifest: true,
  vite:config       target: [Array],
  vite:config       ssrManifest: true,
  vite:config       rollupOptions: {}
  vite:config     },
  vite:config     define: { 'import.meta.vitest': undefined }
  vite:config   },
  vite:config   server: {
  vite:config     preTransformRequests: false,
  vite:config     appType: 'custom',
  vite:config     envPrefix: [ 'VITE_', 'IMBA_', 'OP_', 'TEST_', 'VITEST_' ],
  vite:config     plugins: [ [Array] ],
  vite:config     resolve: { extensions: [Array], dedupe: [Array], conditions: [Array] },
  vite:config     esbuild: { target: 'node16', platform: 'node' },
  vite:config     ssr: { target: 'node', external: [Array] },
  vite:config     build: {
  vite:config       assetsInlineLimit: 0,
  vite:config       ssr: true,
  vite:config       target: 'node16',
  vite:config       minify: false,
  vite:config       rollupOptions: [Object]
  vite:config     },
  vite:config     define: { 'import.meta.vitest': undefined },
  vite:config     worker: { plugins: [Array] },
  vite:config     watch: { ignored: [Array] },
  vite:config     hmr: false,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] },
  vite:config     sourcemapIgnoreList: [Function: isInNodeModules],
  vite:config     middlewareMode: false
  vite:config   },
  vite:config   envPrefix: [ 'VITE_', 'IMBA_', 'OP_', 'TEST_', 'VITEST_' ],
  vite:config   plugins: [
  vite:config     'vite:optimized-deps',
  vite:config     'vite:watch-package-data',
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite-plugin-imba',
  vite:config     'vitest',
  vite:config     'vitest:ssr-replacer',
  vite:config     'vitest:global-setup-plugin',
  vite:config     'vitest:css-disable',
  vite:config     'vitest:resolve-root',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm-helper',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite-plugin-imba-svg',
  vite:config     'vitest:coverage-transform',
  vite:config     'vitest:normalize-optimizer',
  vite:config     'vite:wasm-fallback',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:asset-import-meta-url',
  vite:config     'vite:dynamic-import-vars',
  vite:config     'vite:import-glob',
  vite:config     'vitest:css-empty-post',
  vite:config     'vitest:mocks',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       'vite:optimized-deps',
  vite:config       'vite:watch-package-data',
  vite:config       'vite:pre-alias',
  vite:config       'alias',
  vite:config       'vite-plugin-imba',
  vite:config       'vite:modulepreload-polyfill',
  vite:config       'vite:resolve',
  vite:config       'vite:html-inline-proxy',
  vite:config       'vite:css',
  vite:config       'vite:esbuild',
  vite:config       'vite:json',
  vite:config       'vite:wasm-helper',
  vite:config       'vite:worker',
  vite:config       'vite:asset',
  vite:config       'vite-plugin-imba-svg',
  vite:config       'vite:wasm-fallback',
  vite:config       'vite:define',
  vite:config       'vite:css-post',
  vite:config       'vite:worker-import-meta-url',
  vite:config       'vite:asset-import-meta-url',
  vite:config       'vite:dynamic-import-vars',
  vite:config       'vite:import-glob',
  vite:config       'vite:client-inject',
  vite:config       'vite:import-analysis'
  vite:config     ],
  vite:config     rollupOptions: {},
  vite:config     getSortedPlugins: [Function: getSortedPlugins],
  vite:config     getSortedPluginHooks: [Function: getSortedPluginHooks]
  vite:config   },
  vite:config   resolve: {
  vite:config     mainFields: [ 'imba', 'module', 'jsnext:main', 'jsnext' ],
  vite:config     browserField: false,
  vite:config     conditions: [ 'imba', 'node' ],
  vite:config     extensions: [
  vite:config       '.vitest.node.imba',
  vite:config       '.vitest.imba',
  vite:config       '.node.imba',
  vite:config       '.imba',
  vite:config       '.imba1',
  vite:config       '.mjs',
  vite:config       '.js',
  vite:config       '.ts',
  vite:config       '.jsx',
  vite:config       '.tsx',
  vite:config       '.json'
  vite:config     ],
  vite:config     dedupe: [ 'imba' ],
  vite:config     preserveSymlinks: false,
  vite:config     alias: [ [Object], [Object] ]
  vite:config   },
  vite:config   test: {
  vite:config     globals: true,
  vite:config     benchmark: { include: [Array], includeSource: [Array] },
  vite:config     include: [
  vite:config       '**/*.{test,spec}.{imba,js,mjs,cjs,ts,mts,cts,jsx,tsx}',
  vite:config       'features/**/*.feature'
  vite:config     ],
  vite:config     includeSource: [ '**/*.imba' ],
  vite:config     environment: 'node',
  vite:config     setupFiles: [ 'node_modules/imba/bin/test-setup.all.mjs' ],
  vite:config     exclude: [
  vite:config       '**/node_modules/**',
  vite:config       '**/dist/**',
  vite:config       '**/cypress/**',
  vite:config       '**/.{idea,git,cache,output,temp}/**',
  vite:config       '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*'
  vite:config     ]
  vite:config   },
  vite:config   logLevel: 'error',
  vite:config   configFile: '/Users/abdellah/workspace/scrimba/bundler/node_modules/imba.vitest.config.mjs',
  vite:config   mode: 'test',
  vite:config   root: '/Users/abdellah/workspace/scrimba/bundler',
  vite:config   optimizeDeps: {
  vite:config     disabled: false,
  vite:config     include: [],
  vite:config     exclude: [ 'vitest', 'react', 'imba-hmr' ],
  vite:config     enabled: true,
  vite:config     noDiscovery: true,
  vite:config     entries: [],
  vite:config     esbuildOptions: { preserveSymlinks: false }
  vite:config   },
  vite:config   ssr: {
  vite:config     format: 'esm',
  vite:config     target: 'node',
  vite:config     optimizeDeps: {
  vite:config       disabled: false,
  vite:config       enabled: true,
  vite:config       noDiscovery: true,
  vite:config       entries: [],
  vite:config       exclude: [Array],
  vite:config       include: [],
  vite:config       esbuildOptions: [Object]
  vite:config     }
  vite:config   },
  vite:config   esbuild: { jsxDev: true, sourcemap: 'external', legalComments: 'inline' },
  vite:config   css: { modules: { generateScopedName: [Function (anonymous)] } },
  vite:config   cacheDir: '/Users/abdellah/workspace/scrimba/bundler/node_modules/.vitest',
  vite:config   configFileDependencies: [
  vite:config     '/Users/abdellah/workspace/scrimba/bundler/node_modules/imba.vitest.config.mjs'
  vite:config   ],
  vite:config   inlineConfig: {
  vite:config     logLevel: 'error',
  vite:config     configFile: '/Users/abdellah/workspace/scrimba/bundler/node_modules/imba.vitest.config.mjs',
  vite:config     mode: 'test',
  vite:config     plugins: [
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object]
  vite:config     ],
  vite:config     root: '/Users/abdellah/workspace/scrimba/bundler'
  vite:config   },
  vite:config   base: '/',
  vite:config   rawBase: '/',
  vite:config   publicDir: '/Users/abdellah/workspace/scrimba/bundler/public',
  vite:config   command: 'serve',
  vite:config   isWorker: false,
  vite:config   mainConfig: null,
  vite:config   isProduction: false,
  vite:config   build: {
  vite:config     target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ],
  vite:config     cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ],
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     copyPublicDir: true,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     ssrEmitAssets: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] },
  vite:config     modulePreload: { polyfill: true },
  vite:config     cssMinify: true
  vite:config   },
  vite:config   preview: {
  vite:config     port: undefined,
  vite:config     strictPort: undefined,
  vite:config     host: undefined,
  vite:config     https: undefined,
  vite:config     open: undefined,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   envDir: '/Users/abdellah/workspace/scrimba/bundler',
  vite:config   env: { BASE_URL: '/', MODE: 'test', DEV: true, PROD: false },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(1) {
  vite:config     'fnpd_/Users/abdellah/workspace/scrimba/bundler' => {
  vite:config       dir: '/Users/abdellah/workspace/scrimba/bundler',
  vite:config       data: [Object],
  vite:config       hasSideEffects: [Function: hasSideEffects],
  vite:config       webResolvedImports: {},
  vite:config       nodeResolvedImports: {},
  vite:config       setResolvedCache: [Function: setResolvedCache],
  vite:config       getResolvedCache: [Function: getResolvedCache]
  vite:config     },
  vite:config     set: [Function (anonymous)]
  vite:config   },
  vite:config   createResolver: [Function: createResolver],
  vite:config   appType: 'spa',
  vite:config   experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false },
  vite:config   getSortedPlugins: [Function: getSortedPlugins],
  vite:config   getSortedPluginHooks: [Function: getSortedPluginHooks]
  vite:config } +109ms

@sheremet-va
Copy link
Member

sheremet-va commented Sep 5, 2023

I see that in Vitest 0.34.2 there is imba inside the deps.inline, but in 0.34.3 there is no imba there. I have no idea how you inject it. Do you have any pointers?

@haikyuu
Copy link
Contributor Author

haikyuu commented Sep 6, 2023

@sheremet-va I change the vite config in the vite plugin config method

// config() returns
ssr: { noExternal: [ 'imba', /^imba\// ], external: [] }

All dependencies, specified in ssr.noExternal will be inlined by default.

So that line in the docs seems to not be honored in 0.34.3

@haikyuu
Copy link
Contributor Author

haikyuu commented Sep 6, 2023

Also, I noticed that config.ssr is missing stuff.

{
  optimizeDeps: {
    enabled: true,
    noDiscovery: true,
    disabled: false,
    entries: [],
    exclude: [ 'vitest', 'react' ],
    include: []
  }
}

whereas in 0.34.2 it's

{
  noExternal: [ 'imba', /^imba\// ],
  external: [],
  optimizeDeps: {
    enabled: true,
    noDiscovery: true,
    disabled: false,
    entries: [],
    exclude: [
      'vitest',           '_http_agent',         '_http_client',
      '_http_common',     '_http_incoming',      '_http_outgoing',
      '_http_server',     '_stream_duplex',      '_stream_passthrough',
      '_stream_readable', '_stream_transform',   '_stream_wrap',
      '_stream_writable', '_tls_common',         '_tls_wrap',
      'assert',           'assert/strict',       'async_hooks',
      'buffer',           'child_process',       'cluster',
      'console',          'constants',           'crypto',
      'dgram',            'diagnostics_channel', 'dns',
      'dns/promises',     'domain',              'events',
      'fs',               'fs/promises',         'http',
      'http2',            'https',               'inspector',
      'module',           'net',                 'os',
      'path',             'path/posix',          'path/win32',
      'perf_hooks',       'process',             'punycode',
      'querystring',      'readline',            'readline/promises',
      'repl',             'stream',              'stream/consumers',
      'stream/promises',  'stream/web',          'string_decoder',
      'sys',              'timers',              'timers/promises',
      'tls',              'trace_events',        'tty',
      'url',              'util',                'util/types',
      'v8',               'vm',                  'worker_threads',
      'zlib'
    ],
    include: []
  }
}

@sheremet-va
Copy link
Member

Looks like it overrides more than it should (only optimizeDeps should be overriden).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants