I diffrent JS Bibliotheken Grunzen-contrib-concat wie folgt verwendet, bin Bündelung:Gebündelte JS-Bibliotheken, z.B. eckig, jQuery, lodash nach eval wirft "erfordern nicht definiert ist"
dist7: {
src: [
'lib/jquery/dist/jquery.js',
'lib/ng1.6/angular-animate/angular-animate.js',
'lib/ng1.6/angular-aria/angular-aria.js',
'lib/ng1.6/angular-messages/angular-messages.js',
'lib/api-check/dist/api-check.js',
'lib/angular-formly/dist/formly.js',
'lib/ng1.6/angular-sanitize/angular-sanitize.js',
'lib/angular-ui-router/release/angular-ui-router.js',
'lib/lodash/lodash.js',
'lib/angularjs-toaster/toaster.js',
'lib/moment/min/moment-with-locales.js',
'lib/eventie/eventie.js',
'lib/wolfy87-eventemitter/EventEmitter.js',
'lib/imagesloaded/imagesloaded.js',
'lib/desandro-matches-selector/matches-selector.js',
'lib/doc-ready/doc-ready.js',
'lib/fizzy-ui-utils/utils.js',
'lib/desandro-get-style-property/get-style-property.js',
'lib/get-size/get-size.js',
'lib/outlayer/item.js',
'lib/outlayer/outlayer.js',
'lib/masonry-layout/masonry.js'],
dest: 'dist/js/my-dependencies.js'
}
Wenn ich es funktioniert bin Hinzufügen dist/js/my-dependencies.js
in Script-Tag .
Aber wenn ich eine Anfrage holen mache dann wie ich eval folgende:
fetch('dist/js/my-dependencies.js', {method: 'GET'})
.then(response => response.text()))).then(scr => {
eval(scr)
});
Es thoows Fehler Folowing:
Err in evaling: /cuicui/scripts/js/my-dependencies.js With err:
ReferenceError: require is not defined
at installedModules (eval at <anonymous> (cd.component.js:12), <anonymous>:1:93)
at eval (eval at <anonymous> (cd.component.js:12), <anonymous>:1:554)
at cd.component.js:12
at Array.forEach (<anonymous>)
at cd.component.js:12
at <anonymous>
require wird von einigen Bibliotheken wie angular intern verwendet, aber ich bin mir nicht sicher, wo sie es lösen? –