Closed
Description
Describe the bug
In the svelte.config.js
file, the newly added import.meta.dirname
does not work.
// This works
join(dirname(fileURLToPath(import.meta.url)), 'postcss.config.js')
// This does not work
join(import.meta.dirname, 'postcss.config.js')
// These two values are identical
dirname(fileURLToPath(import.meta.url)) === import.meta.dirname;
The error is not shown in the svelte.config.js
file.
It is only shown in Svelte files.
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
Reproduction
// svelte.config.js
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { join } from 'node:path';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess({
style: {
css: {
postcss: join(import.meta.dirname, 'postcss.config.js'),
},
},
}),
kit: { adapter: adapter() },
};
export default config;
Expected behaviour
Following configuration should work in Node.js v20.11+
join(import.meta.dirname, 'postcss.config.js')
System Info
System:
- OS: macOS 14.2.1
- CPU: (10) arm64 Apple M1 Pro
- Memory: 50.89 MB / 16.00 GB
- Shell: 5.9 - /bin/zsh
Binaries:
- Node: 20.11.0 - ~/.volta/tools/image/node/20.11.0/bin/node
- npm: 10.2.4 - ~/.volta/tools/image/node/20.11.0/bin/npm
- pnpm: 8.15.2 - ~/.volta/bin/pnpm
npmPackages:
- @sveltejs/adapter-node: ^4.0.1 => 4.0.1
- @sveltejs/kit: ^2.5.0 => 2.5.0
- @sveltejs/vite-plugin-svelte: ^3.0.2 => 3.0.2
- svelte: ^4.2.10 => 4.2.10
- vite: ^5.1.1 => 5.1.1
Which package is the issue about?
No response
Additional Information, eg. Screenshots
Node v20.11.0 (LTS)
- [c1a196c897] - (SEMVER-MINOR) esm: add import.meta.dirname and import.meta.filename (James Sumners) #48740