Skip to content

Commit eec3780

Browse files
committed
Merge branch 'develop' into update-from-template-merged
2 parents 13669ae + e486263 commit eec3780

File tree

23 files changed

+1084
-112
lines changed

23 files changed

+1084
-112
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ body:
1515
attributes:
1616
label: "Checklist"
1717
options:
18-
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
18+
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/vaadin-package-json-optimizer/releases/latest)"
1919
required: true
20-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
20+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/vaadin-package-json-optimizer/issues) or [closed](https://github.com/xdev-software/vaadin-package-json-optimizer/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
2121
required: true
2222
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
2323
required: true

.github/ISSUE_TEMPLATE/enhancement.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ body:
1313
attributes:
1414
label: "Checklist"
1515
options:
16-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
16+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/vaadin-package-json-optimizer/issues) or [closed](https://github.com/xdev-software/vaadin-package-json-optimizer/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
1717
required: true
1818
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
1919
required: true

.github/ISSUE_TEMPLATE/question.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ body:
1212
attributes:
1313
label: "Checklist"
1414
options:
15-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
15+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/vaadin-package-json-optimizer/issues) or [closed](https://github.com/xdev-software/vaadin-package-json-optimizer/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
1616
required: true
1717
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
1818
required: true

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@ hs_err_pid*
3333
.classpath
3434
.project
3535

36+
#vaadin/node webpack/frontend stuff
37+
# Ignore Node
38+
node/
39+
40+
# The following files are generated/updated by vaadin-maven-plugin
41+
node_modules/
42+
43+
# Vaadin
44+
package.json
45+
package-lock.json
46+
webpack.generated.js
47+
webpack.config.js
48+
tsconfig.json
49+
types.d.ts
50+
vite.config.ts
51+
vite.generated.ts
52+
**/src/main/frontend/generated/
53+
**/src/main/frontend/index.html
54+
**/src/main/bundles/
55+
*.lock
56+
3657
# == IntelliJ ==
3758
*.iml
3859
*.ipr

.run/Run Demo.run.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Run Demo" type="Application" factoryName="Application">
3-
<option name="MAIN_CLASS_NAME" value="software.xdev.Application" />
4-
<module name="template-placeholder-demo" />
3+
<option name="MAIN_CLASS_NAME" value="software.xdev.vaadin.Application" />
4+
<module name="vaadin-package-json-optimizer-demo" />
55
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
66
<extension name="coverage">
77
<pattern>

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.0.0
2+
3+
_Initial release_

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ You should have the following things installed:
3434
* Ensure that the JDK/Java-Version is correct
3535

3636

37-
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/release.yml?branch=master)](https://github.com/xdev-software/template-placeholder/actions/workflows/release.yml)
37+
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/vaadin-package-json-optimizer/release.yml?branch=master)](https://github.com/xdev-software/vaadin-package-json-optimizer/actions/workflows/release.yml)
3838

3939
Before releasing:
40-
* Consider doing a [test-deployment](https://github.com/xdev-software/template-placeholder/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
40+
* Consider doing a [test-deployment](https://github.com/xdev-software/vaadin-package-json-optimizer/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
4141
* Check the [changelog](CHANGELOG.md)
4242

4343
If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes

README.md

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,100 @@
1-
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
2-
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/check-build.yml?branch=develop)](https://github.com/xdev-software/template-placeholder/actions/workflows/check-build.yml?query=branch%3Adevelop)
1+
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/vaadin-package-json-optimizer?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/vaadin-package-json-optimizer)
2+
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/vaadin-package-json-optimizer/check-build.yml?branch=develop)](https://github.com/xdev-software/vaadin-package-json-optimizer/actions/workflows/check-build.yml?query=branch%3Adevelop)
33

4-
# template-placeholder
4+
# `package.json` optimizer for Vaadin
55

6+
Patches `package.json` and replaces unused packages with an empty package.
7+
8+
This also prevents the installation of the corresponding transitive dependencies and lowers the overall attack surface.
9+
10+
As of Vaadin 24.8 this results in the following:
11+
* at least 280 fewer packages (-55%): ~500 → ~210
12+
* 80MB fewer required storage space (-40%): ~210MB → ~130MB
13+
* overall faster build/`npm install` by processing/downloading less packages
14+
15+
Please note that this is currently intended as a stopgap measure until Vaadin implements [improvements upstream](https://github.com/vaadin/flow/issues/22207).
16+
17+
<details><summary>Currently these npm package groups are overwritten with an empty package</summary>
18+
19+
* `glob`'s and `rollup-plugin-visualizer`'s CLI packages
20+
* Vaadin never uses their CLI and only library methods
21+
* Incorrectly declared dependencies of `transform-ast`
22+
* All Vaadin Pro components and their corresponding packages
23+
* Unused dependencies of `workbox`
24+
25+
Full details are available in the [source code](./vaadin-package-json-optimizer/src/main/java/software/xdev/vaadin/vpjo/VPJOptimizer.java).
26+
27+
</details>
28+
29+
## Usage
30+
31+
`package.json` needs to be modified BEFORE the Vaadin installs all dependencies using `npm install`.
32+
33+
This needs to happen in 2 places:
34+
1. When building the frontend with the build-frontend goal
35+
```xml
36+
<build>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.codehaus.mojo</groupId>
40+
<artifactId>exec-maven-plugin</artifactId>
41+
<version>...</version>
42+
<executions>
43+
<execution>
44+
<id>patch-package-json-overrides</id>
45+
<phase>compile</phase>
46+
<goals>
47+
<goal>java</goal>
48+
</goals>
49+
<configuration>
50+
<mainClass>software.xdev.vaadin.vpjo.Launcher</mainClass>
51+
<arguments>
52+
<argument>${project.basedir}</argument>
53+
<argument>${project.build.directory}</argument>
54+
</arguments>
55+
<includeProjectDependencies>false</includeProjectDependencies>
56+
<includePluginDependencies>true</includePluginDependencies>
57+
<executableDependency>
58+
<groupId>software.xdev</groupId>
59+
<artifactId>vaadin-package-json-optimizer</artifactId>
60+
</executableDependency>
61+
</configuration>
62+
</execution>
63+
</executions>
64+
<dependencies>
65+
<dependency>
66+
<groupId>software.xdev</groupId>
67+
<artifactId>vaadin-package-json-optimizer</artifactId>
68+
<version>...</version>
69+
</dependency>
70+
</dependencies>
71+
</plugin>
72+
...
73+
```
74+
2. When running in dev mode
75+
```xml
76+
<profiles>
77+
<profile>
78+
<id>dev</id>
79+
<activation>
80+
<activeByDefault>true</activeByDefault>
81+
</activation>
82+
<dependencies>
83+
<!-- Only needed as dependency during development not in production! -->
84+
<dependency>
85+
<groupId>software.xdev</groupId>
86+
<artifactId>vaadin-package-json-optimizer</artifactId>
87+
<version>...</version>
88+
</dependency>
89+
</dependencies>
90+
</profile>
91+
...
92+
```
93+
94+
For more information have a look at the [demo's `pom.xml`](./vaadin-package-json-optimizer-demo/pom.xml).
695

796
## Installation
8-
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
97+
[Installation guide for the latest release](https://github.com/xdev-software/vaadin-package-json-optimizer/releases/latest#Installation)
998

1099
## Support
11100
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
@@ -14,4 +103,4 @@ If you need support as soon as possible and you can't wait for any pull request,
14103
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
15104

16105
## Dependencies and Licenses
17-
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
106+
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/vaadin-package-json-optimizer/dependencies)

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## Reporting a Vulnerability
44

5-
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
5+
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/vaadin-package-json-optimizer/security/advisories/new).

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>software.xdev</groupId>
8-
<artifactId>template-placeholder-root</artifactId>
9-
<version>1.0.0-SNAPSHOT</version>
8+
<artifactId>vaadin-package-json-optimizer-root</artifactId>
9+
<version>1.0.1-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<organization>
@@ -15,8 +15,8 @@
1515
</organization>
1616

1717
<modules>
18-
<module>template-placeholder</module>
19-
<module>template-placeholder-demo</module>
18+
<module>vaadin-package-json-optimizer</module>
19+
<module>vaadin-package-json-optimizer-demo</module>
2020
</modules>
2121

2222
<properties>

0 commit comments

Comments
 (0)