ES6 - импорт файлов es5
Я пытаюсь использовать это ( https://github.com/gocardless/es6-angularjs/blob/master/README.md) в качестве отправной точки, а затем включаю загрузочный код JavaScript. Чтобы открыть модал
Но единственное, что происходит:
Potentially unhandled rejection [3] Error loading "components/bootstrap/dist/js" at http://localhost:3010/components/bootstrap/dist/js.js
Error loading "components/bootstrap/dist/js" from "app-compiled/bootstrap" at http://localhost:3010/app-compiled/bootstrap.js
Not Found: http://localhost:3010/components/bootstrap/dist/js.js (WARNING: non-Error used)
Я добавил это в main.js:
import 'bootstrap-js';
//TODO please explain to me why not working
и это в файл loader.config.js:
System.config({
meta: {
...,
'components/bootstrap/dist/js':{ format: 'global', export: 'bootstrap'}
},
map: {
....,
'bootstrap-js': 'components/bootstrap/dist/js'
}
});
1 ответ
Решение
- Пытаться
exports
вместоexport
Вот:
System.config({
meta: {
//...
'components/bootstrap/dist/js':{ format: 'global', exports: 'bootstrap'}
}
//...
});
- Когда ты пишешь
{ format: 'global', exports: 'bootstrap'}
ты пытаешься стать глобальнымbootstrap
переменная. Но такого не существует. Поэтому я думаю, что вы должны удалить мета-линию и исправить карту. Результат должен выглядеть так:
System.config({
meta: {
//...
'components/path/to/jquery': { format: 'global', exports: 'jQuery' },
'components/bootstrap/dist/js/bootstrap': { deps: ['jquery'] }
}
map: {
//...
'jquery': 'components/path/to/jquery',
'bootstrap-js': 'components/bootstrap/dist/js/bootstrap'
}
});