Migrating an Angular Project to Use Liferay npm Bundler 2.x
The Liferay npm bundler is deprecated of Liferay 2024.Q4/7.4 GA129, and it’s planned for future removal.
Follow these steps to migrate your Angular project to use liferay-npm-bundler 2.x. While liferay-npm-bundler 1.x relied on Babel to perform some transformation steps, these transformations are now automatically applied in version 2.x. Therefore, you should remove Babel from your project:
-
Update the
liferay-npm-bundler
dependency in yourpackage.json
to version 2.x:{ "devDependencies": { ... "liferay-npm-bundler": "^2.0.0", ... }, ... }
-
Remove all
liferay-npm-bundler-preset-*
dependencies from yourpackage.json
because liferay-npm-bundler 2.x includes these by default. -
Remove any bundler presets you configured in your
.npmbundlerrc
file. liferay-npm-bundler 2.x includes one smart preset that handles all frameworks automatically. -
Open your
tsconfig.json
file and replace the"module": "amd"
compiler option with the configuration shown below to produce CommonJS modules:{ "compilerOptions": { ... "module": "commonjs", ... } }
-
Delete the
.babelrc
file to remove the Babel configuration. -
Remove Babel from your
package.json
build process so it matches the configuration below:{ "scripts": { "build": "tsc && liferay-npm-bundler" }, ... }
-
Remove the following Babel dependencies from your
package.json
devDependencies:"babel-cli": "6.26.0", "babel-preset-liferay-amd": "1.2.2"
Great! Your project is migrated to use liferay-npm-bundler 2.x.