Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support vue.config.cjs (#5293)
* chore: Update yarn.lock * feat: support vue.config.cjs * fix: vue.config.js prior than cjs * chore: merge upstream
- Loading branch information
1 parent
d8afaa0
commit 4225c30
Showing
5 changed files
with
89 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { join } = require('path') | ||
const Service = require('../lib/Service') | ||
|
||
const mockDir = join(__dirname, 'mockESM') | ||
const configPath = join(mockDir, 'vue.config.cjs') | ||
|
||
const createService = () => { | ||
const service = new Service(mockDir, { | ||
plugins: [], | ||
useBuiltIn: false | ||
}) | ||
service.init() | ||
return service | ||
} | ||
|
||
// vue.config.cjs has higher priority | ||
|
||
test('load project options from package.json', async () => { | ||
const service = createService() | ||
expect(service.projectOptions.lintOnSave).toBe('default') | ||
}) | ||
|
||
test('load project options from vue.config.cjs', async () => { | ||
jest.mock(configPath, () => ({ lintOnSave: true }), { virtual: true }) | ||
const service = createService() | ||
expect(service.projectOptions.lintOnSave).toBe(true) | ||
}) | ||
|
||
test('load project options from vue.config.cjs as a function', async () => { | ||
jest.mock(configPath, () => function () { return { lintOnSave: true } }, { virtual: true }) | ||
const service = createService() | ||
expect(service.projectOptions.lintOnSave).toBe(true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "module", | ||
"vue": { | ||
"lintOnSave": "default" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters