Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/vite/src/node/__tests__/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1696,8 +1696,8 @@ describe('loadConfigFromFile', () => {
expect(messages).toMatchInlineSnapshot(`
[
"(!) Your Vite config uses features that are unsupported by \`configLoader: 'native'\`, which is planned to become the default in a future major version of Vite:
- \`__dirname\` (vite.config.js:3). Use \`import.meta.dirname\` instead
- \`__filename\` (vite.config.js:4). Use \`import.meta.filename\` instead
- \`__dirname\` (vite.config.js:3:29). Use \`import.meta.dirname\` instead
- \`__filename\` (vite.config.js:4:30). Use \`import.meta.filename\` instead
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
]
`)
Expand All @@ -1712,7 +1712,7 @@ describe('loadConfigFromFile', () => {
expect(messages).toMatchInlineSnapshot(`
[
"(!) Your Vite config uses features that are unsupported by \`configLoader: 'native'\`, which is planned to become the default in a future major version of Vite:
- \`__dirname\` (vite.config.ts:10). Use \`import.meta.dirname\` instead
- \`__dirname\` (vite.config.ts:10:29). Use \`import.meta.dirname\` instead
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
]
`)
Expand All @@ -1724,7 +1724,7 @@ describe('loadConfigFromFile', () => {
expect(messages).toMatchInlineSnapshot(`
[
"(!) Your Vite config uses features that are unsupported by \`configLoader: 'native'\`, which is planned to become the default in a future major version of Vite:
- import "./helper" without a file extension (vite.config.js:1). Add the file extension
- import "./helper" without a file extension (vite.config.js:1:23). Add the file extension
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
]
`)
Expand All @@ -1735,7 +1735,7 @@ describe('loadConfigFromFile', () => {
expect(messages).toMatchInlineSnapshot(`
[
"(!) Your Vite config uses features that are unsupported by \`configLoader: 'native'\`, which is planned to become the default in a future major version of Vite:
- import "./plugins" resolves to a directory index (vite.config.js:1). Import the index file directly
- import "./plugins" resolves to a directory index (vite.config.js:1:25). Import the index file directly
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
]
`)
Expand All @@ -1746,7 +1746,7 @@ describe('loadConfigFromFile', () => {
expect(messages).toMatchInlineSnapshot(`
[
"(!) Your Vite config uses features that are unsupported by \`configLoader: 'native'\`, which is planned to become the default in a future major version of Vite:
- JSON import "./data.json" without import attributes (vite.config.js:1). Add \`with { type: 'json' }\`
- JSON import "./data.json" without import attributes (vite.config.js:1:18). Add \`with { type: 'json' }\`
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
]
`)
Expand All @@ -1761,7 +1761,7 @@ describe('loadConfigFromFile', () => {
expect(messages).toMatchInlineSnapshot(`
[
"(!) Your Vite config uses features that are unsupported by \`configLoader: 'native'\`, which is planned to become the default in a future major version of Vite:
- import "./foo" resolves to a JSON file (vite.config.js:1). Import it with a \`.json\` extension and \`with { type: 'json' }\`
- import "./foo" resolves to a JSON file (vite.config.js:1:18). Import it with a \`.json\` extension and \`with { type: 'json' }\`
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
]
`)
Expand All @@ -1783,7 +1783,7 @@ describe('loadConfigFromFile', () => {
expect(messages).toMatchInlineSnapshot(`
[
"(!) Your Vite config uses features that are unsupported by \`configLoader: 'native'\`, which is planned to become the default in a future major version of Vite:
- \`__dirname\` (esm-helper.mjs:1). Use \`import.meta.dirname\` instead
- \`__dirname\` (esm-helper.mjs:1:35). Use \`import.meta.dirname\` instead
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
]
`)
Expand All @@ -1794,7 +1794,7 @@ describe('loadConfigFromFile', () => {
expect(messages).toMatchInlineSnapshot(`
[
"(!) Your Vite config uses features that are unsupported by \`configLoader: 'native'\`, which is planned to become the default in a future major version of Vite:
- ESM syntax in a file loaded as CommonJS (vite.config.js:1). Use a \`.mjs\` extension or set \`"type": "module"\` in the closest package.json
- ESM syntax in a file loaded as CommonJS (vite.config.js:1:1). Use a \`.mjs\` extension or set \`"type": "module"\` in the closest package.json
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
]
`)
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/nativeConfigCompat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ function describeIncompatibility(
item: NativeConfigIncompatibility,
root: string,
): string {
const loc = `${normalizePath(path.relative(root, item.file))}:${item.line}`
// 1-based column so terminals can link `file:line:column` to the exact position
const loc = `${normalizePath(path.relative(root, item.file))}:${item.line}:${item.column + 1}`
switch (item.type) {
case 'dirname':
return `\`__dirname\` (${loc}). Use \`import.meta.dirname\` instead`
Expand Down