-
Notifications
You must be signed in to change notification settings - Fork 41
Migrate an Angular project to bundler 2.x
⚠️ The contents of this wiki have been migrated to theliferay/liferay-frontend-projects
monorepo and more specifically to the to themaintenance/projects/js-toolkit/docs
directory. Development and updates will continue there, and this repo will be archived (ie. switched to read-only mode).
Angular based projects rely on the Typescript compiler to transpile source files and Babel to perform some transformation steps that were needed for the bundler 1.x
to produce a valid artifact (basically wrapping project's code into AMD modules).
With bundler 2.x
, you must keep using Typescript to transpile but you can get rid of Babel as all the transformation steps that bundler 1.x
imposed on the project files are automagically applied for you by bundler 2.x
.
To do that follow the next steps:
Modify: tsconfig.json
From:
{
"compilerOptions": {
...
"module": "amd",
...
}
...
}
To:
{
"compilerOptions": {
...
"module": "commonjs",
...
}
...
}
Delete: .babelrc
Modify: package.json
From:
{
"scripts": {
"build": "tsc && babel --source-maps -d build/resources/main/META-INF/resources src/main/resources/META-INF/resources && liferay-npm-bundler"
},
...
}
To:
{
"scripts": {
"build": "tsc && liferay-npm-bundler"
},
...
}
Modify: package.json
From:
{
"devDependencies": {
...
"babel-cli": "6.26.0",
"babel-preset-liferay-amd": "1.2.2",
...
}
...
}
To:
{
"devDependencies": {
...
🚫 (removed lines) 🚫
...
}
...
}