-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: allow asynchronous vue cli init phase #23936
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3dbc59c
fix:23896 allows asynchronous vue cli init phase
msebas d5351de
Merge branch 'develop' into issue-23896
ZachJW34 ea12ed6
minor tweaks, add system-test
ZachJW34 c261597
Merge branch 'develop' into issue-23896
ZachJW34 4322ecf
Merge branch 'develop' into issue-23896
ZachJW34 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
import debugLib from 'debug' | ||
import type { Configuration } from 'webpack' | ||
//import type { Configuration } from 'webpack' | ||
import type { PresetHandlerResult, WebpackDevServerConfig } from '../devServer' | ||
import { sourceDefaultWebpackDependencies } from './sourceRelativeWebpackModules' | ||
|
||
const debug = debugLib('cypress:webpack-dev-server:vueCliHandler') | ||
|
||
export function vueCliHandler (devServerConfig: WebpackDevServerConfig): PresetHandlerResult { | ||
export async function vueCliHandler (devServerConfig: WebpackDevServerConfig): Promise<PresetHandlerResult> { | ||
const sourceWebpackModulesResult = sourceDefaultWebpackDependencies(devServerConfig) | ||
|
||
try { | ||
const config = require.resolve('@vue/cli-service/webpack.config', { | ||
const Service = require(require.resolve('@vue/cli-service/lib/Service', { | ||
paths: [devServerConfig.cypressConfig.projectRoot], | ||
}) | ||
})) | ||
let service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd()) | ||
|
||
const webpackConfig = require(config) as Configuration | ||
await service.init(process.env.VUE_CLI_MODE || process.env.NODE_ENV) | ||
const webpackConfig = service.resolveWebpackConfig() | ||
|
||
debug('webpack config %o', webpackConfig) | ||
|
||
return { frameworkConfig: webpackConfig, sourceWebpackModulesResult } | ||
} catch (e) { | ||
console.error(e) // eslint-disable-line no-console | ||
throw Error(`Error loading @vue/cli-service/webpack.config.js. Looked in ${require.resolve.paths(devServerConfig.cypressConfig.projectRoot)}`) | ||
throw Error(`Error loading @vue/cli-service/lib/Service or resolving WebpackConfig. Looked in ${require.resolve.paths(devServerConfig.cypressConfig.projectRoot)}`) | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I have not looked at the Vue CLI code in some time. What about users on older versions of Vue CLI? Will they have a problem?
We have tests around this https://github.com/cypress-io/cypress/tree/develop/system-tests/projects/vuecli4-vue2 Vue CLI 4 and Vue 2. Amazingly they are all passing - but I don't understand how this can be the case, unless
service/lib/Service
has always been a thing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the v3 branch of vue-cli contains the file and to me it does not seem like much of the called code has changed.
I think #23605 would allow to move the fix to vue-cli code (e.g. return a promise from their
webpack.config.js
), but the main aim of this pull request is to get the default configuration to work with avue.config.js
and"type": "module"
and I do not know if there are other conflicts on the vue-cli side.