Cannot read property 'data-ck-expando' of undefined when ngOnDestroy - angular8

ckeditor works just fine except that the ngOnDestroy handler crashes.
"dependencies": {
"#angular/common": "8.0.0",
"#angular/compiler": "8.0.0",
"#angular/core": "8.0.0",
"#angular/forms": "8.0.0",
"#angular/platform-browser": "8.0.0",
"#angular/platform-browser-dynamic": "8.0.0",
"#angular/router": "8.0.0",
"#ckeditor/ckeditor5-angular": "1.1.0",
"#ckeditor/ckeditor5-basic-styles": "11.1.4",
"#ckeditor/ckeditor5-build-classic": "12.4.0",
....
"zone.js": "0.10.0"
},
I am using webpack to minimizer with plugin "TerserPlugin".
the problem seems to come from
terserOptions: {
ecma: 6,
ie8: false,
toplevel: true,
module: true,
compress: {
dead_code: true,
warnings: false,
properties: true,
drop_debugger: true,
conditionals: true,
booleans: true,
loops: true,
unused: true,
toplevel: true,
if_return: true,
inline: true,
join_vars: true,
ecma: 6,
module: true,
toplevel: true
},
output: {
comments: false,
beautify: false,
indent_level: 2,
ecma: 6
},
mangle: {
module: true,
toplevel: true
}
}
to tried, i changed zone.js in the polyfills.ts file in this way :
import 'core-js/proposals/reflect-metadata';
import 'zone.js/dist/zone.js';
(window as any).__Zone_disable_toString = true;
require('../manifest.webapp');
But not working for me.
Here is the error :
ERROR TypeError: Cannot read property 'data-ck-expando' of undefined
at Si (4.83409f22a2c74d96c1fe.chunk.js:1)
at Oa._getProxyEmitter (4.83409f22a2c74d96c1fe.chunk.js:1)
at Oa.stopListening (4.83409f22a2c74d96c1fe.chunk.js:1)
at Oa.destroy (4.83409f22a2c74d96c1fe.chunk.js:1)
at Oa.destroy (4.83409f22a2c74d96c1fe.chunk.js:1)
at ea.destroy (4.83409f22a2c74d96c1fe.chunk.js:1)
at Ip.destroy (4.83409f22a2c74d96c1fe.chunk.js:1)
at e.ngOnDestroy (main.83409f22a2c74d96c1fe.bundle.js:1)
at ug (main.83409f22a2c74d96c1fe.bundle.js:1)
at lg (main.83409f22a2c74d96c1fe.bundle.js:1)

In polyfills.ts change this line:
import 'zone.js/dist/zone'; // Included with Angular CLI.
to
import 'zone.js/dist/zone.js'; // Included with Angular CLI.

You need turn off module property. Module (default false) -- Pass true when compressing an ES6 module. Strict mode is implied and the toplevel option as well. Documentation: https://github.com/terser/terser#compress-options
terserOptions: {
compress: {
module: false // here
}
}

delete all the code in polyfill.ts and add below code
import 'zone.js/dist/zone.js'; // Included with Angular CLI.
(window as any).__Zone_disable_toString = true;
This is should resolve your issue

Andrew's answer was what did the trick for me. I'm using ckfinder with a new funcionality to insert raw html code in the editor. I tried to update the zone.js version to 0.10.0, tried to modify the file polyfills.ts too, but it dind't work.
Just turn the module property to false in the following file: webpack.js
The structure is as follow:
terserOptions: {
compress: {
module: false
}
}
Ps.: I can't comment yet since I don't have enough points :(

Related

Error evaluating function `ceil`: argument must be a number

On OSX, after I installed all of dependencies by yarn install, The webpack bundle's output keeps showing the error Error evaluating function ceil: argument must be a number.
I have no idea why this happen but it works on my linux machine with the same package.json
Some info:
webpack: "5.56.0"
less: "^4.1.2"
less-loader: "^10.0.1"
Here is my less-loader config:
{loader: "less-loader"}
It looks like the there is a change of the default options of less based on what I've found in here
https://lesscss.org/usage/#less-options-math
The solution is adding the option for less-loader in webpack config as following:
{
loader: "less-loader",
options: {
lessOptions: {
math: 'always' // <=== add this
}
}
}
Also you should change => strictMath: false
Example (my file config-overrides.js):
const addLessLoader = require("customize-cra-less-loader");
module.exports = override(
addLessLoader({
cssLoaderOptions: {
sourceMap: true,
modules: {
localIdentName: "[hash:base64:8]",
},
},
lessLoaderOptions: {
lessOptions: {
math: "always",
modifyVars: { "#primary-color": "#2a4365" },
javascriptEnabled: true,
strictMath: false,
},
},
})
);

TypeOrm + Sqlite works only in development [React Native + Expo]

On development the app database works very well but when I generated APK it just not work, I can't use the database.
I found this answare of jbenzshawel:
1º: yarn add metro-minify-terser
2º: Update the metro config to keep class names and file names. Add the following to the metro.config.js transformer:
minifierConfig: {
ecma: 8,
keep_classnames: true,
keep_fnames: true,
module: true,
mangle: {
module: true,
keep_classnames: true,
keep_fnames: true,
},
},
So if you need to create metro.config.js add the following:
const { getDefaultConfig } = require('expo/metro-config');
const config = getDefaultConfig(__dirname);
config.transformer.minifierPath = 'metro-minify-terser';
config.transformer.minifierConfig = {
ecma: 8,
keep_classnames: true,
keep_fnames: true,
module: true,
mangle: {
module: true,
keep_classnames: true,
keep_fnames: true,
},
};
module.exports = config;

Ngx\clipboard Not working with Aot and Rollup

I have tried to implement aot in my app but While building my app with aot and rollup gets this error.I have used ngx-clipboard.
'ngx-clipboard/src/index' is imported by
wwwroot\app\aot\app\app.module.ngfactory.js, but could not be resolved ΓÇô
treating it as an external dependency
'ngx-clipboard/src/window.service' is
imported by wwwroot\app\aot\app\app.module.ngfactory.js, but could not be
resolved ΓÇô treating it as an external dependency
'ngx-clipboard/src/clipboard.directive' is imported by
wwwroot\app\aot\app\patients\patient-result\patient-
result.component.ngfactory.js, but could not be resolved ΓÇô treating it as
an external dependency
'ngx-clipboard/src/clipboard.service' is
imported by wwwroot\app\aot\app\patients\patient-result\patient-
result.component.ngfactory.js, but could not be resolved ΓÇô treating it a
s an external dependency
'ngx-clipboard/src/document.service' is imported by
wwwroot\app\aot\app\app.module.ngfactory.js, but could not be resolved ΓÇô
treating it as an external dependency
'ngx-clipboard/src/clipboard.service' is imported
by wwwroot\app\aot\app\app.module.ngfactory.js, but could not be resolved
ΓÇô treating it as an external dependency
No name was provided for external module 'ngx-clipboard/src/index' in
options.globals ΓÇô guessing 'import10'
No name was provided for external module 'ngx-clipboard/src/window.service'
in options.globals ΓÇô guessing 'import13'
No name was provided for external module 'ngx-
clipboard/src/clipboard.directive' in options.globals ΓÇô guessing
'import5'
No name was provided for external module 'ngx-
clipboard/src/clipboard.service' in options.globals ΓÇô guessing 'import28'
No name was provided for external module 'ngx-
clipboard/src/document.service' in options.globals ΓÇô guessing 'import27'
Here is my package.json
{
"name": "demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"aot": "node_modules/.bin/ngc -p wwwroot/tsconfig-aot.json",
"rollup": "node_modules/.bin/rollup -c wwwroot/rollup-config.js",
"cleanup": "rimraf wwwroot/app/aot && rimraf wwwroot/build.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"angular/animations": "4.1.3",
"angular/common": "4.1.3",
"angular/compiler": "4.1.3",
"angular/compiler-cli": "4.1.3",
"angular/core": "4.1.3",
"angular/forms": "4.1.3",
"angular/http": "4.1.3",
"angular/material": "2.0.0-beta.6",
"angular/platform-browser": "4.1.3",
"angular/platform-browser-dynamic": "4.1.3",
"angular/platform-server": "4.1.3",
"angular/router": "4.1.3",
"angular/upgrade": "4.1.3",
"core-js": "2.4.1",
"ngx-clipboard": "8.0.3",
"rxjs": "5.4.0",
"systemjs": "0.20.13",
"zone.js": "0.8.11"
},
"devDependencies": {
"ngx-window-token": "0.0.2"
"rollup": "0.43.0",
"rollup-plugin-commonjs": "8.0.2",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-uglify": "2.0.1",
"typescript": "2.2.2",
"rimraf": "2.6.1"
}
}
Here is my tsconfig-aot.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true
},
"files": [
"app/app.module.ts",
"app/main-aot.ts"
],
"angularCompilerOptions": {
"genDir": "app/aot",
"skipMetadataEmit": true
}
}
Here is my rollup.config.js
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'wwwroot/app/main-aot.js',
dest: 'wwwroot/build.js', // output a single application bundle
sourceMap: false,
format: 'iife',
onwarn: function (warning) {
// Skip certain warnings
// should intercept ... but doesn't in some rollup versions
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
// console.warn everything else
console.warn(warning.message);
},
plugins: [
nodeResolve({ jsnext: true, module: true }),
commonjs({
include: 'node_modules/**',
}),
uglify()
]
}
Thanks in advance
Try this:
In rollup-config.js import alias
import alias from 'rollup-plugin-alias';
Under plugins add
'ngx-clipboard': __dirname + '/node_modules/ngx-clipboard/dist/',
'ngx-window-token': __dirname + '/node_modules/ngx-window-token/dist/'

Aurelia Bundling error

I am using a modified aurelia-navigation-skeleton to build my project (modified because I am also adding a servicestack backend).
First the error:
[16:33:59] Error tracing npm:crypto-browserify#3.11.0/example/bundle.js at file:///C:/MyProjectPath/jspm_packages/npm/crypto-browserify#3.11.0/example/bundle.js
Error: Unable to calculate canonical name to bundle file:///test.js. Ensure that this module sits within the baseURL or a wildcard path config.
at getCanonicalNamePlain (C:\MyProjectPath\node_modules\systemjs-builder\lib\utils.js:227:13)
at getCanonicalName (C:\MyProjectPath\node_modules\systemjs-builder\lib\utils.js:150:19)
at C:\MyProjectPath\node_modules\systemjs-builder\lib\trace.js:565:36
at run (C:\MyProjectPath\node_modules\karma\node_modules\core-js\modules\es6.promise.js:87:22)
at C:\MyProjectPath\node_modules\karma\node_modules\core-js\modules\es6.promise.js:100:28
at flush (C:\MyProjectPath\node_modules\karma\node_modules\core-js\modules\_microtask.js:18:9)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
I am not using crpto-browserify myself so I assume it is a dependency somewhere either within the skeleton or within Aurelia itself.
Project layout:
ProjectRoot
-- build (from skeleton)
-- tasks
-- src (standard aurelia layout here)
-- app.js/main.js/app.html
-- views
-- resources
-- etc...
-- default.html
-- node_modules
-- jspm_packages
-- jspm.config.js
-- package.json
jspm.config.js
System.config({
defaultJSExtensions: true,
transpiler: "typescript",
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
map: {
"aurelia-animator-css": "npm:aurelia-animator-css#1.0.1",
"aurelia-api": "npm:aurelia-api#3.1.1",
"aurelia-authentication": "npm:aurelia-authentication#3.3.0",
"aurelia-bootstrapper": "npm:aurelia-bootstrapper#2.1.1",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection#1.3.0",
"aurelia-dialog": "npm:aurelia-dialog#1.0.0-beta.3.0.1",
"aurelia-fetch-client": "npm:aurelia-fetch-client#1.1.1",
"aurelia-framework": "npm:aurelia-framework#1.1.0",
"aurelia-pal-browser": "npm:aurelia-pal-browser#1.1.0",
"aurelia-router": "npm:aurelia-router#1.2.1",
"aurelia-templating-binding": "npm:aurelia-templating-binding#1.3.0",
"bootstrap": "github:twbs/bootstrap#3.3.7",
"font-awesome": "npm:font-awesome#4.7.0",
"moment": "npm:moment#2.17.1",
"numeral": "npm:numeral#2.0.4",
"servicestack-client": "npm:servicestack-client#0.0.26",
"text": "github:systemjs/plugin-text#0.0.9",
"typescript": "npm:typescript#2.2.1",
"github:jspm/nodelibs-assert#0.1.0": {
"assert": "npm:assert#1.4.1"
},
...
...
...
}
bundle.js
var gulp = require('gulp');
var bundler = require('aurelia-bundler');
var bundles = require('../bundles.js');
var config = {
force: true,
baseURL: '.',
configPath: './jspm.config.js',
bundles: bundles.bundles
};
gulp.task('bundle', ['build'], function() {
return bundler.bundle(config);
});
gulp.task('unbundle', function() {
return bundler.unbundle(config);
});
bundles.js
module.exports = {
"force": true,
"packagePath": ".",
"configPath": [ // SystemJS/JSPM configuration files
"./jspm.config.js"
],
"injectionConfigPath": "./jspm.config.js",
"bundles": {
"dist/app-build": {
"includes": [
"[**/*.js]",
"**/*.html!text",
"**/*.css!text"
],
"options": {
"inject": true,
"minify": true,
"depCache": false,
"rev": true
}
},
"dist/aurelia": {
"includes": [
"aurelia-api",
"aurelia-authentication",
"aurelia-framework",
"aurelia-pal-browser",
"aurelia-bootstrapper",
"aurelia-dependency-injection",
"aurelia-dialog",
"aurelia-fetch-client",
"aurelia-router",
"aurelia-animator-css",
"aurelia-templating-binding",
"aurelia-polyfills",
"aurelia-templating-binding",
"aurelia-templating-resources",
"aurelia-templating-router",
"aurelia-loader-default",
"aurelia-history-browser",
"aurelia-logging-console",
"moment",
"numeral",
"servicestack-client",
"bootstrap",
"bootstrap/css/bootstrap.css!text"
],
"options": {
"inject": true,
"minify": true,
"depCache": false,
"rev": true
}
}
}
};
The error means nothing to me and other posts about this error talk about changing the BaseURL, but I don't know what I would change it to to make this work. Any help would be appreciated.

Cannot get grunt to find link task

I am using:
grunt-cli v0.1.11
grunt v0.4.1
Here is my package.json
{
"name": "Example",
"version": "0.0.1",
"private": true,
"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "~0.1.11",
"grunt-contrib-jshint": "~0.7.1"
}
}
Here is my gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
src: ['Gruntfile.js', 'src/app/**/*.js', 'src/config.js', 'tests/app/**/*.js'],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true,
globals: {
require: true,
define: true,
requirejs: true,
describe: true,
expect: true,
it: true
}
}
}
});
// Load JSHint task
grunt.loadNpmTasks('grunt-contrib-jshint');
// Default task.
grunt.registerTask('default', 'lint');
};
I have installed: grunt-contrib-jshint package and I can see it in the node_modules directory.
When I do:
> grunt
I expect the default lint task to execute but instead I get:
Warning: Task "lint" not found. Use --force to continue.
Any ideas?
You need to rename lint to jshint.
Alternatively, add a task alias
grunt.registerTask('lint', ['jshint']);
I've noticed you have grunt-cli as a devDependency, but you should install it globally instead of listing it in your package.json
npm i -g grunt-cli