frontend-maven-plugin
frontend-maven-plugin copied to clipboard
yarn 1.0 arguments support (proxy)
I try to build a jHipster-based app with updated libs.
maven runs
yarn run webpack:prod --https-proxy=http://proxy:8080 --proxy=http://proxy:8080
ok until yarn.version<=0.28.4
but if yarn >=1.0, then it failed with warning.
warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
If should be:
yarn run webpack:prod https-proxy=http://proxy:8080 proxy=http://proxy:8080
then it works. But frontend-maven-plugin should be updated here for this. thanks.
frontend-maven-plugin v1.6 os windows 10
Looks like a warning only, so it shouldn't fail the build? Must be something else.
sure, but it leads to this breaking change in 1.0.0:
Breaking: Commands run via yarn run are now automatically forwarded trailing options Maël Nison - (#4152)
I continue to investigate.
Hey there,
@ludoo0d0a: based on https://github.com/yarnpkg/yarn/issues/4375#issuecomment-328871888 I think the generated command should be
yarn run --https-proxy=http://proxy:8080 --proxy=http://proxy:8080 webpack:prod
(Keep the dashes but put them before the script being run.)
I had the same issue when we switched from npm to yarn and the build started failing because the proxy parameters were sent to tslint which doesn't understand them
yarn run lint --https-proxy=http://proxy:8080 --proxy=http://proxy:8080
yarn run v1.3.2
$ tslint src/**/*.ts{,x} --https-proxy=http://proxy:8080 --proxy=http://proxy:8080
error: unknown option `--https-proxy=http://proxy:8080'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@eirslett If you agree with the change I will do it. Am I right that it will be done in https://github.com/eirslett/frontend-maven-plugin/blob/960bd8cba502ac30ecaf9e414f65b9969effb2f1/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/YarnTaskExecutor.java#L92?
Same issue here.
As a workaround there is the flag:
<yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven>
With this flag set the wrong params are not passed from the plugin and yarn will use the proxy settings configured in the local machine. I think it could be possible also to set the parameters manually in the execution arguments.
Something like:
<execution> <id>yarn install</id> <goals> <goal>yarn</goal> </goals> <configuration> <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven> <arguments>install ----https-proxy=http://proxy:8080 --proxy=http://proxy:8080</arguments> </configuration> </execution>
and
<execution> <id>webpack build prod</id> <goals> <goal>yarn</goal> </goals> <phase>generate-resources</phase> <configuration> <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven> <arguments>run --https-proxy=http://proxy:8080 --proxy=http://proxy:8080 webpack:prod</arguments> </configuration> </execution>
i think there is a few unclear things.
for frontend-maven-plugin, It will add the proxy(here it is the proxy for maven) as additional parameters to the command line
Question 1
but if there is a "dev": "webpack-dev-server && someothercall" . the additional parameter will work or not ? (i mean the params will work for both or the last one only?)
i did some test for this:
"a": "yarn run b && yarn run c",
"b": "yarn --version",
"c": "yarn install"
we run yarn run a --https-proxy=http://127.0.0.1:80 --proxy=http://127.0.0.1:80. (the proxy is wrong , so that if it really use the params for the yarn install here, it will fail)
result: task b- > ok; task c -> network error. the taks c really use the proxy parameter here.
we change the script to (taks c first.)
"a": "yarn run c && yarn run b",
"b": "yarn --version",
"c": "yarn install"
we run yarn run a --https-proxy=http://127.0.0.1:80 --proxy=http://127.0.0.1:80. (the proxy is wrong proxy, so that if it really use the params for the yarn install here, it will fail)
result: task c => ok; taks b=>ok. the task c didn't use the proxy here at all
while. here it is quite clear. if we define multiple tasks in the same line, the params just work for the last one, so for the frontend-maven-plugin, add the proxy parameter didn't achieve the aim at all.
i think it would be better to remove this proxy things here. ortherwise, if people write some task like yarn install && yarn webpack and use this plugin, they may not aware that the proxy doesn't work at all. if people really need a proxy for the yarn, they should set it in the .yarnrc file. (at least, set the <yarnInheritsProxyConfigFromMaven> to false, if peope want to use it, they know aware what to do next)
if want to keep it, we have to change the way we add the parameter to cater for the multiple tasks scenario).
Further more, even we made it. here we use the maven proxy for yarn proxy is also a risk point. what if the proxys for maven and npm are different....
Question 2
Even the parameter doesn't work as we expected, why it trigger error now ? let's take a sample
//package.json
"scripts": {
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js"
}
if we have something in the pom.xml like
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<executions>
<execution>
<id>webpack build dev</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run webpack</arguments>
</configuration>
</execution>
</executions>
</plugin>
so in the end, it will run node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --https-proxy=http://127.0.0.1:80 --proxy=http://127.0.0.1:80 which will cause a error. because Unknown arguments: https-proxy, proxy
it seems like yarn will run any possible task which may not need the proxy params...
**Conclustion, i still think remove the proxy here is good option. **
- the current solution can't cater the multiple tasks scenarios, like
yarn run c && yarn run b - not all the task need this proxy params. it may cause failure if we add the proxy for every tasks. @eirslett
i make a pull request in the #675 . i was intend to remove all the proxy feature for the DefaultYarnRunner side.
but since we also support the install yarn and node. so it seems like let people config yarn in the .yarnrc may not fit our purpose.
but anyway, we really should disable the yarnInheritsProxyConfigFromMaven, it really cause a lot of troubles for the people who did use the proxy....
I am facing the same issue, I have yarn version 1.3.2 and frontend-maven-plugin version 1.6.
I am able to manually invoke the prod-build script but it fails when it is invoked via the Maven plugin.
The script is defined like this "prod-build": "jest && cross-env NODE_ENV=production webpack --config webpack.config.prod.js --progress" inside the package.json file.
The error is:
[ERROR] ...
[ERROR] Unknown arguments: https-proxy, proxy
[ERROR] error Command failed with exit code 1.
@dg-grow-virgiliu-ratoi pass the config parameters in the pom.xml file will solve this
-
<%_ if (clientPackageManager === 'yarn') { _%> -
<yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven> -
<%_ } else if (clientPackageManager === 'npm') { _%> -
<npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven> -
</configuration>
Indeed, I tried that and it did not work because I had put it in the wrong execution declaration. Now that you mentioned it made me realize my mistake. Thank you.
I have the same issue with Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:yarn:
Calling:
yarn run build-prod --https-proxy=http://proxy:8080 --proxy=proxy:8080
Causing:
[ERROR] Unknown option: '--https-proxy'
[ERROR] Unknown option: '--proxy'
I think it should be:
yarn --https-proxy=http://proxy:8080 --proxy=proxy:8080 run build-prod
Reported this in issue #796
It's resolved in version 1.12.0