Как я уже сказал здесь , мне удалось сделать это следующим образом.
Сначала добавьте эти package.json
зависимости: @babel/core
, @babel/preset-env
и babel-loader
:
yarn add @babel/core @babel/preset-env babel-loader --exact --dev
(протестировано со следующими версиями:
"@babel/core": "7.6.4",
"@babel/preset-env": "7.6.3",
"babel-loader": "8.0.6",
)
Теперь добавьте следующие строки вверху src/main/webapp/app/polyfills.ts
:
import 'core-js/stable';
import 'regenerator-runtime/runtime';
В webpack/webpack.common.js
, после
{
test: /manifest.webapp$/,
loader: 'file-loader',
options: {
name: 'manifest.webapp'
}
},
добавить следующие строки:
{
test: /\.js/,
use: {
loader: 'babel-loader',
options: {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"firefox": "60",
"ie": "11"
},
"useBuiltIns": "entry",
"corejs": 3
}
]
]
}
},
exclude: /@babel(?:\/|\\{1,2})runtime|core-js/,
},
И, наконец, изменить target
на es5
в tsconfig.json
& tsconfig-aot.json
.
Вот мой полный тест:
sudo rm -rf /dev/shm/myproject
cd /dev/shm/
mkdir myproject
cd myproject
mkdir /dev/shm/m2cache /dev/shm/yarncache
sudo tee myproject.jdl <<EOF
application {
config {
baseName MyProject
clientPackageManager yarn
jhiPrefix mp
enableTranslation false
languages [fr]
nativeLanguage fr
packageName com.mycompany.myproject
prodDatabaseType postgresql
skipUserManagement true
}
entities *
}
entity MyEntity {
label String
}
EOF
JHIPSTER_VERSION=v6.3.1
sudo chown -R 1000:1000 . /dev/shm/m2cache /dev/shm/yarncache
docker run -it --rm --name jhipster -v "$(pwd):/home/jhipster/app" -v /dev/shm/m2cache:/home/jhipster/.m2 -v /dev/shm/yarncache:/home/jhipster/.cache/yarn -v "$HOME/.gitconfig:/home/jhipster/.gitconfig:ro" jhipster/jhipster:$JHIPSTER_VERSION jhipster import-jdl ./myproject.jdl --force
# WAIT FOR THE APPLICATION TO BE GENERATED
docker run -it --rm --name jhipster -v "$(pwd):/home/jhipster/app" -v /dev/shm/m2cache:/home/jhipster/.m2 -v /dev/shm/yarncache:/home/jhipster/.cache/yarn -p 9000:9000 -p 8080:8080 jhipster/jhipster:$JHIPSTER_VERSION yarn add @babel/core @babel/preset-env babel-loader --exact --dev
# WAIT FOR THE YARN COMMAND TO END
echo "
import 'core-js/stable';
import 'regenerator-runtime/runtime';
$(cat src/main/webapp/app/polyfills.ts)
" | sudo -u '#1000' tee src/main/webapp/app/polyfills.ts
cat > /dev/shm/webpack.patch <<EOF
{
test: /\.js/,
use: {
loader: 'babel-loader',
options: {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"firefox": "60",
"ie": "11"
},
"useBuiltIns": "entry",
"corejs": 3
}
]
]
}
},
exclude: /@babel(?:\/|\\{1,2})runtime|core-js/,
},
EOF
sudo -u '#1000' sed -i $'/Ignore warnings about System.import in Angular/{e cat /dev/shm/webpack.patch\n}' webpack/webpack.common.js
for FILE in tsconfig.json tsconfig-aot.json; do
sudo -u '#1000' sed -i 's/"target": "es6"/"target": "es5"/' $FILE
done
docker run -it --rm --name jhipster -v "$(pwd):/home/jhipster/app" -v /dev/shm/m2cache:/home/jhipster/.m2 -v /dev/shm/yarncache:/home/jhipster/.cache/yarn -p 9000:9000 -p 8080:8080 jhipster/jhipster:$JHIPSTER_VERSION bash -c "./mvnw & yarn start --host 0.0.0.0"
Спасибо https://www.thebasement.be/working-with-babel-7-and-webpack/, https://babeljs.io/docs/en/usage и https://github.com/zloirock/core-js/issues/514#issuecomment-523524472 за подсказки!