Aurelia - Adding bootstrap 4 causes my project to fail - aurelia

I have decided to add bootstrap 4 to my Aurelia project.
It is an asp.net 2 solution with webpack.
This is what I did...
I removed bootstrap 3 and added bootstrap 4 via npm.
I added popper.js using npm next.
I rebuilt the solution which compiled ok.
I then ran the solution to find I now have the following error.
content - script.bundle.js:333 loading pref showConsoleLogs before prefs were initialised, you will not get the correct result
getPref # content-script.bundle.js:333
(anonymous) # content-script.bundle.js:481
a # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:521
a # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:593
a # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:621
a # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1346
a # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1662
a # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:2097
a # content-script.bundle.js:1
u # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:2106
(anonymous) # content-script.bundle.js:1
(anonymous) # content-script.bundle.js:2100
ReferenceError: $ is not defined
at Object.65 (bootstrap.js:3849)
at __webpack_require__ (bootstrap d7bcc5cf3ba589d57197:659)
at fn (bootstrap d7bcc5cf3ba589d57197:85)
at Object.boot(validation - renderer - custom - attribute.js:20)
at __webpack_require__ (bootstrap d7bcc5cf3ba589d57197:659)
at fn (bootstrap d7bcc5cf3ba589d57197:85)
at WebpackLoader.<anonymous>(aurelia - loader - webpack.js:176)
at step (aurelia - loader - webpack.js:36)
at Object.next(aurelia - loader - webpack.js:17)
at aurelia- loader - webpack.js:11
Promise rejected (async)
(anonymous) # aurelia-bootstrapper.js:146
(anonymous) # aurelia-bootstrapper.js:145
Promise resolved (async)
run # aurelia-bootstrapper.js:136
(anonymous) # aurelia-bootstrapper.js:161
45 # app.js?v = W7oxVndIkrRrS4plh4l6MCNBU4PUsPEnfFxcjfVxtDg:16384
__webpack_require__ # bootstrap d7bcc5cf3ba589d57197: 659
fn # bootstrap d7bcc5cf3ba589d57197: 85
83 # app.js?v = W7oxVndIkrRrS4plh4l6MCNBU4PUsPEnfFxcjfVxtDg:27388
__webpack_require__ # bootstrap d7bcc5cf3ba589d57197: 659
0.__webpack_exports__.e # bootstrap d7bcc5cf3ba589d57197: 708
(anonymous) # bootstrap d7bcc5cf3ba589d57197: 708
client.js:82[HMR] connected
here is my webpack vendor file.
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('vendor.css');
module.exports = ({ prod } = {}) => {
const isDevBuild = !prod;
return [{
stats: { modules: false },
resolve: {
extensions: ['.js']
},
module: {
loaders: [
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
{ test: /\.css(\?|$)/, loader: extractCSS.extract([isDevBuild ? 'css-loader' : 'css-loader?minimize']) }
]
},
entry: {
vendor: [
'aurelia-event-aggregator',
'aurelia-fetch-client',
'aurelia-framework',
'aurelia-history-browser',
'aurelia-logging-console',
'aurelia-pal-browser',
'aurelia-polyfills',
'aurelia-route-recognizer',
'aurelia-router',
'aurelia-templating-binding',
'aurelia-templating-resources',
'aurelia-templating-router',
'aurelia-validation',
'jquery',
'bootstrap',
'bootstrap/dist/css/bootstrap.css',
],
},
output: {
path: path.join(__dirname, 'wwwroot', 'dist'),
publicPath: 'dist/',
filename: '[name].js',
library: '[name]_[hash]',
},
plugins: [
extractCSS,
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
new webpack.DllPlugin({
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
name: '[name]_[hash]'
})
].concat(isDevBuild ? [] : [
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
])
}]
};
I do not have the depth of knowledge to decifer these and figure I have left out a step in the installation of bootstrap 4.
Does anybody know how bootstrap 4 should be installed into a webpack project?

Have a look at this pull request to aurelia-skeleton-navigation repository
https://github.com/aurelia/skeleton-navigation/pull/874
It bumps up bootstrap dependency to v4

Related

Error while integrating peerjs with nuxtjs (vue.js)

installing:
npm i peerjs
/plugins/peerjs.js
import Peer from 'peerjs'
export default Peer
nuxt.config.js
plugins: [
{ src: "~/plugins/peerjs.js", ssr: true }
],
Browser error:
client.js?06a0:103 TypeError: Cannot set properties of undefined
(setting '_events')
at i (peerjs.min.js?a0bc:46)
at i (peerjs.min.js?a0bc:66)
at _callee2$ (index.js?f26e:87)
at tryCatch (runtime.js?96cf:63)
at Generator.invoke [as _invoke] (runtime.js?96cf:294)
at Generator.eval [as next] (runtime.js?96cf:119)
at asyncGeneratorStep (asyncToGenerator.js?1da1:3)
at _next (asyncToGenerator.js?1da1:25)
_callee$ # client.js?06a0:103 tryCatch # runtime.js?96cf:63 invoke # runtime.js?96cf:294 eval # runtime.js?96cf:119 asyncGeneratorStep #
asyncToGenerator.js?1da1:3
_next # asyncToGenerator.js?1da1:25 eval # asyncToGenerator.js?1da1:32 eval # asyncToGenerator.js?1da1:21 eval # client.js?06a0:65
Promise.catch (asíncrono) eval # client.js?06a0:115 eval #
client.js:1294 ./.nuxt/client.js # app.js:35
webpack_require # runtime.js:854 fn # runtime.js:151 0 # app.js:9767
webpack_require # runtime.js:854 checkDeferredModules # runtime.js:46 webpackJsonpCallback # runtime.js:33 (anónimo) #
app.js:1
Setting { src: '~/plugins/peerjs.js' , mode: 'server'} fixed the issue.
Strange since it should either be mode: 'client' as shown in the documentation but I guess that PeerJS relies in fact on Node and not on client's window.

Vue3 / vite External Component

Seems like i'm stuck with my problems with loading a external umd component in vue.
I try to do something similar as
Vue 3 external component/plugin loading in runtime
This works for me using vue2 and webpack
Now I'm using Vue3/Vite and also the same source as in the Question above.
But when resolving the external component promise i get the following error when :
vue.js:1184 [Vue warn]: Unhandled error during execution of async component loader
at <AsyncComponentWrapper>
at <DemoComponent>
at <HelloWorld msg="Hello Vue 3.0 + Vite" >
at <App>
warn # vue.js:1184
logError # vue.js:1357
handleError # vue.js:1349
onError # vue.js:4637
(anonymous) # vue.js:4677
Promise.catch (async)
setup # vue.js:4676
callWithErrorHandling # vue.js:1300
setupStatefulComponent # vue.js:7561
setupComponent # vue.js:7522
mountComponent # vue.js:5264
processComponent # vue.js:5240
patch # vue.js:4861
mountChildren # vue.js:5043
processFragment # vue.js:5203
patch # vue.js:4854
componentEffect # vue.js:5357
reactiveEffect # vue.js:339
effect # vue.js:314
setupRenderEffect # vue.js:5322
mountComponent # vue.js:5280
processComponent # vue.js:5240
patch # vue.js:4861
mountChildren # vue.js:5043
processFragment # vue.js:5203
patch # vue.js:4854
componentEffect # vue.js:5357
reactiveEffect # vue.js:339
effect # vue.js:314
setupRenderEffect # vue.js:5322
mountComponent # vue.js:5280
processComponent # vue.js:5240
patch # vue.js:4861
mountChildren # vue.js:5043
processFragment # vue.js:5203
patch # vue.js:4854
componentEffect # vue.js:5357
reactiveEffect # vue.js:339
effect # vue.js:314
setupRenderEffect # vue.js:5322
mountComponent # vue.js:5280
processComponent # vue.js:5240
patch # vue.js:4861
render # vue.js:5937
mount # vue.js:4168
app.mount # vue.js:9324
(anonymous) # main.js:7
Show 16 more frames
external-component.js:11 Uncaught (in promise) TypeError: Chaining cycle detected for promise #<Promise>
at <anonymous>
at HTMLScriptElement.<anonymous> (external-component.js:11)
this is the Code for the promise
export default async function externalComponent(url) {
const name = url.split(`/`).reverse()[0].match(/^(.*?)\.umd/)[1];
if (window[name]) return window[name];
console.log('run');
window[name] = new Promise((resolve, reject) => {
script.async = true;
script.addEventListener(`load`, () => {
resolve(window[name]);
});
script.addEventListener(`error`, () => {
reject(new Error(`Error loading ${url}`));
});
script.src = url;
document.head.appendChild(script);
});
return window[name];
}
and use this in my DemoComponent:
<script lang="ts">
import externalComponent from '../external-component';
import { defineAsyncComponent } from 'vue'
const asyncComponent = defineAsyncComponent(
() => externalComponent(`http://localhost:8200/MyComponent/MyComponent.umd.min.js`)
)
export default {
name: 'DemoComponent',
components: {
MyComponent:asyncComponent
},
....
Can somebody help me with this?
update:
If import vue from vue/dist/vue.esm-bundler and set to global, then no need to change Vite config, and no need to load vue from cdn.
import * as Vue from 'vue/dist/vue.esm-bundler';
window.Vue = Vue;
After trying the link above, I had gotten the vue warn invalid vnode type symbol(static) (symbol) error.
By adding the following config in Vite.config.js, it works for me.
// vite.config.js
import { viteExternalsPlugin } from 'vite-plugin-externals'
export default {
plugins: [
viteExternalsPlugin({
vue: 'Vue'
}),
]
}
https://github.com/crcong/vite-plugin-externals

Vue-cli 3 - Webpack 4: cannot load images with .webp format using the image-webpack-loader

I am trying to load images in Vue components with the extension .webp
<v-parallax :src="require('#/assets/images/hero.webp')">
I added the image-webpack-loader module
yarn add image-webpack-loader --dev
vue.config.js
const webpack = require('webpack')
module.exports = {
configureWebpack: {
module: {
rules: [
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
webp: {
quality: 80
}
}
}
]
}
]
}
}
}
but I get an error in asset optimization during compilation
94% asset optimization
ERROR Failed to compile with 1 errors 18:57:32
error in ./src/assets/images/hero.webp
Module parse failed: Unexpected character '�' (1:4)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
# ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-16f8e3e2","hasScoped":true,"optionsId":"0","buble":{"transforms":{}}}!./node_modules/
vue-loader/lib/selector.js?type=template&index=0!./src/components/Home/Heading.vue 11:24-60
# ./src/components/Home/Heading.vue
# ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"/Users/yves/Developments/myprojects/node_modules/.cac
he/cache-loader"}!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/views/Home.vue
# ./src/views/Home.vue
# ./src/router.js
# ./src/main.js
# multi (webpack)-dev-server/client/index.js (webpack)/hot/dev-server.js ./src/main.js
what's wrong with my webpack settings ?
change test .. to
test: /.(gif|png|jpe?g|webp|svg)$/i,
and here we rae

Rally - Error - hydrateModel is not a function?

Question : I am new to Rally APP development, trying to build a simple application with a Release dropdown , when selected populates the grid.
However when I select the value, I am getting the following error Based upon this error
1. What does this mean ? - Uncaught TypeError: this.store.hydrateModel is not a function at constructor.initComponent" , and how to resolve this ?
====================================================================
App.js?_dc=0.59785698231437:43 Data: [constructor]
08:43:48.080 sdk-debug.js:185210 Uncaught TypeError: this.store.hydrateModel is not a function
at constructor.initComponent (sdk-debug.js:185210)
at constructor (sdk-debug.js:30211)
at constructor.callParent (sdk-debug.js:4469)
at constructor [as _componentConstructor] (sdk-debug.js:34291)
at constructor.callParent (sdk-debug.js:4469)
at constructor (sdk-debug.js:144823)
at constructor.callParent (sdk-debug.js:4469)
at constructor (sdk-debug.js:185132)
at new constructor (sdk-debug.js:5100)
at eval (eval at getInstantiator (sdk-debug.js:5720), <anonymous>:3:8)
initComponent # sdk-debug.js:185210
constructor # sdk-debug.js:30211
callParent # sdk-debug.js:4469
constructor # sdk-debug.js:34291
callParent # sdk-debug.js:4469
constructor # sdk-debug.js:144823
callParent # sdk-debug.js:4469
constructor # sdk-debug.js:185132
constructor # sdk-debug.js:5100
(anonymous) # VM20:3
instantiate # sdk-debug.js:5692
(anonymous) # sdk-debug.js:2303
_loadData # App.js?_dc=0.59785698231437:45
fire # sdk-debug.js:10046
continueFireEvent # sdk-debug.js:11447
fireEventArgs # sdk-debug.js:11425
prototype.fireEventArgs # sdk-debug.js:42297
object.(anonymous function) # sdk-debug.js:195692
fireEvent # sdk-debug.js:11411
onListSelectionChange # sdk-debug.js:149617
object.(anonymous function) # sdk-debug.js:195692
fire # sdk-debug.js:10046
continueFireEvent # sdk-debug.js:11447
fireEventArgs # sdk-debug.js:11425
fireEvent # sdk-debug.js:11411
maybeFireSelectionChange # sdk-debug.js:95171
doSingleSelect # sdk-debug.js:95145
doSelect # sdk-debug.js:94983
selectWithEvent # sdk-debug.js:94717
onItemClick # sdk-debug.js:95543
fire # sdk-debug.js:10046
continueFireEvent # sdk-debug.js:11447
fireEventArgs # sdk-debug.js:11425
prototype.fireEventArgs # sdk-debug.js:42297
fireEvent # sdk-debug.js:11411
processUIEvent # sdk-debug.js:96924
handleEvent # sdk-debug.js:96850
(anonymous) # VM60:7
wrap # sdk-debug.js:10800
==========================================================================
Code Below
enter code here
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
//specify the layout over here
defaults: { margin:10 },
// layout: 'border',
items: [
{ xtype:'container', itemId:'drop-downContainer',layout:'hbox' },
{ xtype:'container', itemId:'gridContainer',layout:'hbox' }
],
//var userStories: undefined;
launch: function() {
enter code here console.log('Entering the launch function');
this._loadUserStores();
},
_loadUserStores: function()
{ console.log("Entering the Load User Stories...");
var releaseComboBox = Ext.create('Rally.ui.combobox.ReleaseComboBox',{
itemId: 'releaseDropDown',
listeners: {
load: function(data,records,success){
console.log("Load is complete");
},
select: this._loadData,
scope: this
}
});
this.down('#drop-downContainer').add(releaseComboBox);
},
_loadData: function(myStore,data,success)
{ console.log("Entering the onLoad Data...");
console.log("Store --",myStore);
console.log("Data: ",data);
var datagrid= Ext.create('Rally.ui.grid.Grid',{
store: myStore,
columnCfgs: ['Name', 'ReleaseStartDate"', 'ReleaseDate', 'ObjectID', 'State', 'PlannedVelocity']
});
console.log("DataGrid is complete...");
//this.down('#gridContainer').add(datagrid);
}
});
The problem you're running into is myStore is not a store- it's the release combo box.
I'd check out the easy button for scoping apps to timeboxes: https://help.rallydev.com/apps/2.1/doc/#!/guide/timebox_filtering
And here's another example showing how to load/update a grid based on a combobox filter:
https://help.rallydev.com/apps/2.1/doc/#!/example/filterable-grid

angular 2 + npm install package not working

Whenever I install a new package via npm install my angular 2 import is not recognizing the package and my browser returns 404 error.
For example, I've been trying to install the following package:
https://github.com/dougludlow/ng2-bs3-modal
and this is what my browser returns:
GET http://localhost:3000/node_modules/ng2-bs3-modal/ng2-bs3-modal 404 (Not Found)fetchTextFromURL # system.src.js:1154(anonymous function) # system.src.js:1710ZoneAwarePromise # angular2-polyfills.js:589(anonymous function) # system.src.js:1709(anonymous function) # system.src.js:2734(anonymous function) # system.src.js:3308(anonymous function) # system.src.js:3575(anonymous function) # system.src.js:3960(anonymous function) # system.src.js:4419(anonymous function) # system.src.js:4671(anonymous function) # system.src.js:406ZoneDelegate.invoke # angular2-polyfills.js:332Zone.run # angular2-polyfills.js:227(anonymous function) # angular2-polyfills.js:576ZoneDelegate.invokeTask # angular2-polyfills.js:365Zone.runTask # angular2-polyfills.js:263drainMicroTaskQueue # angular2-polyfills.js:482ZoneTask.invoke # angular2-polyfills.js:434
angular2-polyfills.js:332 Error: Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-bs3-modal/ng2-bs3-modal(…)
Although I can see that node_modules\ng2-bs3-modal is existing.
What's wrong here?
You need to configure SystemJS to load right files from the library.
You could try the following configuration:
<script>
System.configure({
map: {
'ng2-bs3-modal': 'node_modules/ng2-bs3-modal'
},
packages: {
'ng2-bs3-modal': {
format: 'register',
defaultExtension: 'js'
}
}
});
(...)
</script>