Skip to content

Commit 8a24572

Browse files
authored
feat(config): include column in config incompatibility location (#23064)
1 parent 8c2a87d commit 8a24572

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎packages/vite/src/node/__tests__/config.spec.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,8 +1696,8 @@ describe('loadConfigFromFile', () => {
16961696
expect(messages).toMatchInlineSnapshot(`
16971697
[
16981698
"(!) 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:
1699-
- \`__dirname\` (vite.config.js:3). Use \`import.meta.dirname\` instead
1700-
- \`__filename\` (vite.config.js:4). Use \`import.meta.filename\` instead
1699+
- \`__dirname\` (vite.config.js:3:29). Use \`import.meta.dirname\` instead
1700+
- \`__filename\` (vite.config.js:4:30). Use \`import.meta.filename\` instead
17011701
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
17021702
]
17031703
`)
@@ -1712,7 +1712,7 @@ describe('loadConfigFromFile', () => {
17121712
expect(messages).toMatchInlineSnapshot(`
17131713
[
17141714
"(!) 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:
1715-
- \`__dirname\` (vite.config.ts:10). Use \`import.meta.dirname\` instead
1715+
- \`__dirname\` (vite.config.ts:10:29). Use \`import.meta.dirname\` instead
17161716
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
17171717
]
17181718
`)
@@ -1724,7 +1724,7 @@ describe('loadConfigFromFile', () => {
17241724
expect(messages).toMatchInlineSnapshot(`
17251725
[
17261726
"(!) 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:
1727-
- import "./helper" without a file extension (vite.config.js:1). Add the file extension
1727+
- import "./helper" without a file extension (vite.config.js:1:23). Add the file extension
17281728
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
17291729
]
17301730
`)
@@ -1735,7 +1735,7 @@ describe('loadConfigFromFile', () => {
17351735
expect(messages).toMatchInlineSnapshot(`
17361736
[
17371737
"(!) 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:
1738-
- import "./plugins" resolves to a directory index (vite.config.js:1). Import the index file directly
1738+
- import "./plugins" resolves to a directory index (vite.config.js:1:25). Import the index file directly
17391739
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
17401740
]
17411741
`)
@@ -1746,7 +1746,7 @@ describe('loadConfigFromFile', () => {
17461746
expect(messages).toMatchInlineSnapshot(`
17471747
[
17481748
"(!) 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:
1749-
- JSON import "./data.json" without import attributes (vite.config.js:1). Add \`with { type: 'json' }\`
1749+
- JSON import "./data.json" without import attributes (vite.config.js:1:18). Add \`with { type: 'json' }\`
17501750
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
17511751
]
17521752
`)
@@ -1761,7 +1761,7 @@ describe('loadConfigFromFile', () => {
17611761
expect(messages).toMatchInlineSnapshot(`
17621762
[
17631763
"(!) 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:
1764-
- import "./foo" resolves to a JSON file (vite.config.js:1). Import it with a \`.json\` extension and \`with { type: 'json' }\`
1764+
- import "./foo" resolves to a JSON file (vite.config.js:1:18). Import it with a \`.json\` extension and \`with { type: 'json' }\`
17651765
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
17661766
]
17671767
`)
@@ -1783,7 +1783,7 @@ describe('loadConfigFromFile', () => {
17831783
expect(messages).toMatchInlineSnapshot(`
17841784
[
17851785
"(!) 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:
1786-
- \`__dirname\` (esm-helper.mjs:1). Use \`import.meta.dirname\` instead
1786+
- \`__dirname\` (esm-helper.mjs:1:35). Use \`import.meta.dirname\` instead
17871787
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
17881788
]
17891789
`)
@@ -1794,7 +1794,7 @@ describe('loadConfigFromFile', () => {
17941794
expect(messages).toMatchInlineSnapshot(`
17951795
[
17961796
"(!) 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:
1797-
- 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
1797+
- 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
17981798
Set \`VITE_CONFIG_NATIVE_IGNORE_WARNING=true\` to suppress this warning.",
17991799
]
18001800
`)

‎packages/vite/src/node/nativeConfigCompat.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ function describeIncompatibility(
179179
item: NativeConfigIncompatibility,
180180
root: string,
181181
): string {
182-
const loc = `${normalizePath(path.relative(root, item.file))}:${item.line}`
182+
// 1-based column so terminals can link `file:line:column` to the exact position
183+
const loc = `${normalizePath(path.relative(root, item.file))}:${item.line}:${item.column + 1}`
183184
switch (item.type) {
184185
case 'dirname':
185186
return `\`__dirname\` (${loc}). Use \`import.meta.dirname\` instead`

0 commit comments

Comments
 (0)