Module not found

I created small project

login-view.js

import {PolymerElement} from "@polymer/polymer/polymer-element.js";
import "@polymer/iron-iconset-svg/iron-iconset-svg.js";
import "@polymer/iron-icon/iron-icon.js";
import "@polymer/iron-form/iron-form.js";
import "@polymer/paper-tabs/paper-tabs.js";
import "@polymer/paper-tabs/paper-tab.js";
import "@polymer/iron-pages/iron-pages.js";
import "@vaadin/vaadin-button/vaadin-button";
import "@vaadin/vaadin-text-field/vaadin-text-field";
import "@vaadin/vaadin-text-field/vaadin-password-field";
import "@vaadin/vaadin-ordered-layout/vaadin-vertical-layout";
import {html} from "@polymer/polymer/lib/utils/html-tag.js";

import {styles} from "./login-view_styles";

LoginView.java

@Theme(value = Lumo.class, variant = Lumo.DARK)
@PageTitle(PAGE_LOGIN_TITLE)
@Route(PAGE_LOGIN_URL)
@RouteAlias(value = "")
@Tag("login-view")
@JsModule("./src/views/login/login-view.js")
@Viewport(VIEW_PORT)
public class LoginView extends PolymerTemplate<TemplateModel> {

So my questions

  1. Why it don’t compile in production mode?
  2. Why problems only with iron-form, iron-pages and paper-tabs. For example iron-icon and iron-iconset-svg compile normal. And I can see their dependencies in package.json
  3. I read new article https://vaadin.com/blog/community-answer-understanding-inversion-of-control-and-dependency-injection and its source https://github.com/alejandro-du/community-answers/tree/master/dependency-injection. Why people always add package-lock.json, package.json and webpack.config.js to repositories? I can generate them when building a project

iron-icon and iron-iconset-svg happen to be used by Vaadin so they are automatically installed. Any other dependency you use, you need to install. For this you have two options:

  1. Annotate the Java class using @NpmPackage(name="@polymer/iron-form", version="^3.0.0")
  2. Use npm install --save @polymer/iron-form to install the dependency.

If you use @NpmPackage then the build will make sure that package.json contains the correct entries. In that case you do not strictly need to commit that file. If you install with npm install --save then package.json is the file where it is recorded that your project needs the given dependency and you must commit it.

The information about exact version numbers used is stored in package-lock.json. If you installed @polymer/iron-form using ^3.0.0 as the version number, it means you need 3.0.0 or newer. That the build actually installed and used version 3.0.1 is recorded in package-lock.json. If you commit it, then other people who build the project will also get version 3.0.1. If you do not commit it and version 3.0.2 is released, people will get 3.0.2 when building your project.