0

In our typescript 2.3.4 project(ionic2 & angular 4) using Visual Code, we are integrating third party "3D-Carousel". We are getting following errors:

typescript error Cannot write file '/projectfolder/src/assets/js/3d-carousel/FWDUltimate3DCarousel.js' because it would overwrite input file.

typescript error Cannot write file '/projectfolder/src/assets/js/3d-carousel/init-3dcarousel.js' because it would overwrite input file.

Following is the component code:

import { Component, ElementRef, NgZone } from '@angular/core';
import { Events } from 'ionic-angular';
import '../../../assets/js/3d-carousel/FWDUltimate3DCarousel.js';
import carousel3d from '../../../assets/js/3d-carousel/init-3dcarousel.js';

@Component({
   selector: 'command-3d-Carousel',
   templateUrl: 'Cmd3dCarouselWidget.html'
})
export class Cmd3dCarouselWidget {

constructor(public events: Events, private el: ElementRef, private zone: NgZone) {
}
ngAfterViewInit() {
    this.zone.runOutsideAngular(() => {
    carousel3d(this.el.nativeElement);
    });
}
}

Have checked all the suggestions like making "allowJs": true excluding the carousel Js files in tsconfig.json file. Updating typescript versions etc.The issue still persists.

The build process completes sometimes & the app runs(rarely once in a while), but most of the times the app crashes as a result of the above error's(i.e build process fails at "transpile started").

What can i do for fix it ? Thanks in advance!!

0

1 Answer 1

0

We did manage to solve the issue. Actually the way we were calling 3rd party libraries was wrong. Below is the code needed for the issue to fix:

MyWidget.ts

import { Component, ElementRef, NgZone } from '@angular/core';
import { Events } from 'ionic-angular';
declare var carouselComponent: any; 

@Component({
  selector: 'command-3d-Carousel',
  templateUrl: 'Cmd3dCarouselWidget.html'
})

export class Cmd3dCarouselWidget {

   constructor(public events: Events, private el: ElementRef, private zone: NgZone) {
}
ngAfterViewInit() {
    this.zone.runOutsideAngular(() => {
    carouselComponent(this.el.nativeElement);
    });
}
}

init-3dcarousel.js

var carouselComponent = function carousel3d(ele) {

carousel = new FWDUltimate3DCarousel({

    //required settings
    carouselHolderDivId: "myDiv",
    carouselDataListDivId: "carouselData",
    displayType: "fluidwidth",
    autoScale: "yes",
    carouselWidth: 940,
    carouselHeight: 538,
    ...
    ...
}

index.html

<!-- Third party scripts for 3D Carousel -->
<script src="assets/js/FWDUltimate3DCarousel.js"></script>
<script src="assets/js/init-3dcarousel.js"></script>

What we observed was that the external js files were not being compiled correctly by typescript as we were using wrong approach for using 3rd party lib's in ionic app.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.