Module Federation remotes naming - webpack-5

Going through the tutorials of how to use the module federation host and remotes I faced the issue with naming when using TS
For example I have next folder structure
--packages
--host
--remote1
--remote2
And in my host webpack config I am referencing remotes as follow:
...
"remotes": {
"#asd/remote1-app": "remote1#http://localhost:3001",
"#asd/remote2-app": "remote2#http://localhost:3002"
}
...
And then when I am importing from "#asd/remote1-app" I have the error
TS2307: Cannot find module '#asd/remote1-app' or its corresponding type declarations
I having the folder that contains packages folder with all the microfrontends I noticed that after running yarn inside the node_modules I have the folder #asd with packages inside with the naming as it is describe in the package.json -> name
I have the questions:
why these packages are installed themselves? and why by the package.json name?
does this error influence something?

Related

Install Scrapy in apache airflow will cause INVALID_ARGUMENT

I`m trying to install Scrapy from PyPi using below command.
gcloud composer environments update $(AIRFLOW_ENVIRONMENT_NAME) \
--update-pypi-packages-from-file requirements.txt \
--location $(AIRFLOW_LOCATION)
requirements.txt is like this.
google-api-python-client==1.7.*
google-cloud-datastore==1.7.*
Scrapy==2.0.0
After running gcloud command, It will cause an invalid argument but it runs successfully in the local environment.
gcloud composer environments update xxxx \
--update-pypi-packages-from-file requirements.txt \
--location asia-northeast1
ERROR: (gcloud.composer.environments.update) INVALID_ARGUMENT: Found 1 problem:
1) Error validating key Scrapy. PyPi dependency name is not formatted properly. It must be lowercase and follow the format of 'identifier' specified in PEP-508.
Is there any way to install?
As the previous answer stated, the error that you are receiving now is quite clear and it's caused by the wrong formatting of the dependency. It should be scrapy==2.0.0 instead of Scrapy==2.0.0 inside the requirements.txt.
I would like to add that to avoid the installation error when you fix the formatting, you should add one more dependency to your list and that is attrs==19.2.0. I was able to install your requirements to my environment by specifying the following list:
google-api-python-client==1.7.*
google-cloud-datastore==1.7.*
scrapy==2.0.0
attrs==19.2.0
Even though you adjust package name in requirements.txt file according to PEP-508 document prerequisites, formatting certan package name in lowercase layout scrapy==2.0.0, the issue most probably will remain the same and updating process will stuck with the error:
Failed to install PyPI packages
Generally, this kind of error appears then the source PyPI package has some external dependencies or this package is sensitive on some system-level libraries that GCP Composer doesn't support.
In this case a vendor recommends two ways either using KubernetesPodOperator to build own custom image and use it in particular Kubernetes Pod or deploy PyPi package as a local Python library, uploading shared object libraries for the PyPI dependency to Airflow /plugins directory, find more info here.

Multiple webpack bundles with browserslist and babel preset-env

I am bundling using Webpack 4.
I have multiple Webpack configurations exported in webpack.config.js.
First configuration is to bundle lient code targeting browsers.
Second configuration is to bundle server code targeting node.
I am specifying these browsers and node targets using browserslist in package.json.
I need to specify different browserslists for client and server bundles, but I only have one browserslist key in package.json.
How can I specify different browserslists using package.json?
You don't have to use package.json. If you create a file called .browserslistrc or browserslist at the root of your project, you can use a different configuration.
# Any general config goes at the very top, above any section headers
# ...
# Put section headers in [brackets]
[node]
supports es6-modules
[web]
>1% and not dead
Then call webpack and set BROWSERSLIST_ENV:
BROWSERSLIST_ENV=dev webpack -c webpack.dev.js # Build development
BROWSERSLIST_ENV=prod webpack -c webpack.prod.js # Build production
Your webpack command may be different depending on your configuration.

Why does AWS elastic beanstalk fail to build my app?

I have an app written in Go, which I attempted to deploy to EB.
When trying to access it, I get an Error 502 from nginx, presumably because the app is not running.
Looking at logs, I get a lot of errors like
14:01:29 build.1 | application.go:10:2: cannot find package "github.com/aws/aws-sdk-go/aws" in any of:
14:01:29 build.1 | /opt/elasticbeanstalk/lib/go/src/github.com/aws/aws-sdk-go/aws (from $GOROOT)
14:01:29 build.1 | /var/app/current/src/github.com/aws/aws-sdk-go/aws (from $GOPATH)
Despite the fact, that I have all of my dependencies included in the application bundle under a vendor subdirectory. How come EB does not use vendoring? According to the dashboard, it is running Go 1.9, so vendoring should be supported.
You need to set your GOPATH in your EBS to the root of your project directory, assuming there is a src directory where your vendor directory is located.
For instance, pretend this is your project structure:
app/
src/
vendor/
And pretend that project is located in ~/home, which makes its location ~/home/app.
Then your GOPATH should be set to ~/home/app. Go will attempt to access the dependencies through $GOPATH/src/vendor.
But if this were the kind of structure you were using before, then you would need to have your GOPATH updated during local development as well, so if you aren't already doing that then I imagine you're using a different kind of setup... this solution, however, will work as long as your project is structured as I described above.

Can't find jetty's root.war

I'm trying to build a docker image with my war file and jetty, and the tutorials seem pretty straght forward except for one thing.
FROM jetty
ADD mysample.war /var/lib/jetty/webapps/root.war
EXPOSE 8080
but I don't have /var/lib/jetty/webapps/root.war on my system. Brew installed jetty into /usr/local/Cellar/jetty/9.4.8.v20171121 but there isn't a root.war under the path.
I'm running macOS 10.12.6 if that matters.
If you are using the official docker image ...
https://hub.docker.com/_/jetty/
.. the /var/lib/jetty path is the ${jetty.base} directory.
When your Dockerfile uses:
ADD mysample.war /var/lib/jetty/webapps/root.war
It is taking your mysample.war and putting it in ${jetty.base}/webapps/ with the special reserved name root.war that uses contextPath = "/".
The locally installed path /usr/local/Cellar/jetty/9.4.8.v20171121 has nothing to do with your docker image, and its likely not a ${jetty.base} directory (it looks like a ${jetty.home} directory path)
If you had used the following instead ...
ADD mysample.war /var/lib/jetty/webapps/hello.war
Then that war would have been deployed to contextPath = "/hello", meaning you would access that via the general url ...
<scheme>://<host:port>/<contextPath>/<resourceInWar>
Examples:
http://localhost:8080/hello/
https://machine.com/hello/main.css
Reference: https://www.eclipse.org/jetty/documentation/9.4.x/automatic-webapp-deployment.html

Uploading files to a bluemix app and pointing to them from configuration files

I am trying to upload files to my bluemix app and I am having problems using and understanding the file system. After I have succesfully uploaded files I want to give their path on my configuration files.
Specifically, I want to upload a jar file to the server and later use it as javaagent.
I have tried approaching this isuue from several directions.
I see that I can create a folder in the liberty_buildpack and place the files inside I can later access it on the compilation-release phases from the tmp folder:
/tmp/buildpacks/ibm-websphere-liberty-buildpack/lib/liberty_buildpack/my_folder
Also I can see that in the file system that I see when building and deploying the app I can copy only to the folder located in:
/app
So I copied the JAR file to the app file and set it as a javaagent using 2 method:
Manually set enviorment variable JAVA_OPTS with java agent to point to /app/myjar.jar using cf set-env
Deploy a war file of the app using cf push from wlp server and set the java agent inside the server.xml file and attribute genericJvmArguments
Both of those methods didnt work, and either the deploy phase of the application failed or my features simply didnt work.
So I tried searching the application file system using cf files and came up with the app folder, but strangly it didn't have the same file as the folder I deploy and I couldn't find any connection to the deployed folder ot the build pack.
Can someone explain how this should be done correctly? namely, uploading the file and then how should I point to it from the enviorment variable/server file?
I mean should it be /app/something or maybe other path?
I have also seen the use of relative paths like #droplet.sandbox maybe its the way to address those files? and how should I access those folders from cf files
Thanks.
EDIT:
As I have been instructed in the comments I have added the jar file to the system, the problem is that when I add the javaagent variable to the enviorment variable JAVA_OPTS the deploy stage fails with the timeout error:
payload: {... "reason"=>"CRASHED", "exit_status"=>32, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>
1433864527}
The way I am assigning the javaagent is as follows:
cf set-env myApp JAVA_OPTS "path/agent.jar"
I have tried adding several location:
1. I have found that if I add the jar files to my WebContent folder I can find it in: /app/wlp/usr/servers/defaultServer/apps/myapp.war/resources/
2. I have copied the jar file from the /tmp location in the compilation phase to /home/vcap/app/agent.jar
3. I have located the jar file in /app/.java/jre/lib
none of those 3 paths worked.
I found out that if I give a wrong path the system behaves the same so it may be a path problem.
Any ideas?
Try this:
Put your agent jars in a folder called ".profile.d" inside your WAR package;
cf se your-app JAVA_OPTS -javaagent:/home/vcap/app/.profile.d/your.jar ;
Push the war to Bluemix.
Not sure if this is exactly the right answer, but I am using additional jar files in my Liberty application, so maybe this will help.
I push up a myapp.war file to bluemix. Within the war file, inside the WEB-INF folder, I have a lib folder that contains a number of jar files. The classes in those jar files are then used within the java code of my application.
myapp.war/WEB-INF/lib/myPlugin.jar
You could try doing something like that with the jar file(s) you need, building them into the war file.
Other than that, you could try the section Overlaying the JRE from the bluemix liberty documentation to add jars to the JRE.