Ngx\clipboard не работает с Aot и Rollup

Я пытался внедрить aot в свое приложение, но при создании моего приложения с помощью aot и rollup возникает эта ошибка. Я использовал ngx-буфер обмена.

'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'

Вот мой 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"
 }
 }

Вот мой 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
}
}

Вот мой файл 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()
]
}

заранее спасибо


person user3505487    schedule 06.07.2017    source источник


Ответы (1)


Попробуй это:

В rollup-config.js импортируйте псевдоним

import alias from 'rollup-plugin-alias';

В плагинах добавить

'ngx-clipboard': __dirname + '/node_modules/ngx-clipboard/dist/',
'ngx-window-token': __dirname + '/node_modules/ngx-window-token/dist/'
person galskab    schedule 31.07.2017