Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ body:
attributes:
label: "Checklist"
options:
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/vaadin-package-json-optimizer/releases/latest)"
required: true
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ body:
attributes:
label: "Checklist"
options:
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
required: true
Expand Down
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ hs_err_pid*
.classpath
.project

#vaadin/node webpack/frontend stuff
# Ignore Node
node/

# The following files are generated/updated by vaadin-maven-plugin
node_modules/

# Vaadin
package.json
package-lock.json
webpack.generated.js
webpack.config.js
tsconfig.json
types.d.ts
vite.config.ts
vite.generated.ts
**/src/main/frontend/generated/
**/src/main/frontend/index.html
**/src/main/bundles/
*.lock

# == IntelliJ ==
*.iml
*.ipr
Expand Down
4 changes: 2 additions & 2 deletions .run/Run Demo.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Demo" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="software.xdev.Application" />
<module name="template-placeholder-demo" />
<option name="MAIN_CLASS_NAME" value="software.xdev.vaadin.Application" />
<module name="vaadin-package-json-optimizer-demo" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<extension name="coverage">
<pattern>
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1.0.0

_Initial release_
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct


## 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)
## 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)

Before releasing:
* Consider doing a [test-deployment](https://github.com/xdev-software/template-placeholder/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* 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.
* Check the [changelog](CHANGELOG.md)

If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
Expand Down
99 changes: 94 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,100 @@
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
[![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)
[![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)
[![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)

# template-placeholder
# `package.json` optimizer for Vaadin

Patches `package.json` and replaces unused packages with an empty package.

This also prevents the installation of the corresponding transitive dependencies and lowers the overall attack surface.

As of Vaadin 24.8 this results in the following:
* at least 280 fewer packages (-55%): ~500 → ~210
* 80MB fewer required storage space (-40%): ~210MB → ~130MB
* overall faster build/`npm install` by processing/downloading less packages

Please note that this is currently intended as a stopgap measure until Vaadin implements [improvements upstream](https://github.com/vaadin/flow/issues/22207).

<details><summary>Currently these npm package groups are overwritten with an empty package</summary>

* `glob`'s and `rollup-plugin-visualizer`'s CLI packages
* Vaadin never uses their CLI and only library methods
* Incorrectly declared dependencies of `transform-ast`
* All Vaadin Pro components and their corresponding packages
* Unused dependencies of `workbox`

Full details are available in the [source code](./vaadin-package-json-optimizer/src/main/java/software/xdev/vaadin/vpjo/VPJOptimizer.java).

</details>

## Usage

`package.json` needs to be modified BEFORE the Vaadin installs all dependencies using `npm install`.

This needs to happen in 2 places:
1. When building the frontend with the build-frontend goal
```xml
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>...</version>
<executions>
<execution>
<id>patch-package-json-overrides</id>
<phase>compile</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>software.xdev.vaadin.vpjo.Launcher</mainClass>
<arguments>
<argument>${project.basedir}</argument>
<argument>${project.build.directory}</argument>
</arguments>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<executableDependency>
<groupId>software.xdev</groupId>
<artifactId>vaadin-package-json-optimizer</artifactId>
</executableDependency>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>software.xdev</groupId>
<artifactId>vaadin-package-json-optimizer</artifactId>
<version>...</version>
</dependency>
</dependencies>
</plugin>
...
```
2. When running in dev mode
```xml
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<!-- Only needed as dependency during development not in production! -->
<dependency>
<groupId>software.xdev</groupId>
<artifactId>vaadin-package-json-optimizer</artifactId>
<version>...</version>
</dependency>
</dependencies>
</profile>
...
```

For more information have a look at the [demo's `pom.xml`](./vaadin-package-json-optimizer-demo/pom.xml).

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

## Support
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).
Expand All @@ -14,4 +103,4 @@ If you need support as soon as possible and you can't wait for any pull request,
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.

## Dependencies and Licenses
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/vaadin-package-json-optimizer/dependencies)
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Reporting a Vulnerability

Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/vaadin-package-json-optimizer/security/advisories/new).
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.xdev</groupId>
<artifactId>template-placeholder-root</artifactId>
<artifactId>vaadin-package-json-optimizer-root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

Expand All @@ -15,8 +15,8 @@
</organization>

<modules>
<module>template-placeholder</module>
<module>template-placeholder-demo</module>
<module>vaadin-package-json-optimizer</module>
<module>vaadin-package-json-optimizer-demo</module>
</modules>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"packageRules": [
{
"description": "Ignore project internal dependencies",
"packagePattern": "^software.xdev:template-placeholder",
"packagePattern": "^software.xdev:vaadin-package-json-optimizer",
"datasources": [
"maven"
],
Expand Down
85 changes: 0 additions & 85 deletions template-placeholder-demo/pom.xml

This file was deleted.

Loading