PeterStaev / nativescript-photo-editor

🎨 Easily edit an image in your NativeScript app (crop, draw, etc)
Apache License 2.0
47 stars 15 forks source link

Compilation issue in a web-shared project in photo-editor.d.ts #14

Closed thomaspetrou closed 5 years ago

thomaspetrou commented 5 years ago

Hello Peter and everyone else,

Thank for this awesome plugin!

I have a web-shared-angular project and both VissualStudioCode and "tns build android --bundle" report

IDE Error

{ "resource": ......../node_modules/nativescript-photo-editor/photo-editor.d.ts", "owner": "typescript", "code": "2307", "severity": 8, "message": "Cannot find module 'image-source'.", "source": "ts", "startLineNumber": 13, "startColumn": 29, "endLineNumber": 13, "endColumn": 43 }

Build Error

`ERROR in node_modules/nativescript-photo-editor/photo-editor.d.ts(13,29): error TS2307: Cannot find module 'image-source'.

Webpack compilation complete. Executing webpack failed with exit code 2.`

This code is easily fixed in my project by changing line 13 in photo-editor.d.ts from import { ImageSource } from "image-source"; -> import { ImageSource } from "tns-core-modules/image-source;"

I dont have time to investigate further at this stage but i thought to share with the community.

Thanks

Thomas

PeterStaev commented 5 years ago

Hey @thomaspetrou , this is probably because you do not have default import paths in your tsconfig file, like so: https://github.com/PeterStaev/nativescript-photo-editor/blob/0d131213c432b0bdbd9078d7fffb9265ecdd4736/demo/tsconfig.json#L14-L22

thomaspetrou commented 5 years ago

Thanks!, You are right! :) The situation is slightly more complicated for a web-shared project, where there is a tsconfig.tns.json. At this point in time this is overriden by webpack during its upgrade process. If you change it to include the above it throws a warning during installation of plugins.

The current project contains a tsconfig.tns.json file located at ...../tsconfig.tns.json that differs from the one in the new version of the nativescript-dev-webpack plugin located at ...../node_modules/nativescript-dev-webpack/templates/tsconfig.tns.json. Some of the plugin features may not work as expected until you manually update the tsconfig.tns.json file or automatically update it using "./node_modules/.bin/update-ns-webpack --configs" command.

I have ignored it :) and it seems that everything works. For completeness this is the new tsconfig.tns.json { "extends": "./tsconfig", "compilerOptions": { "module": "es2015", "moduleResolution": "node", "paths": { "~/*": [ "src/*" ], "*": [ "./node_modules/*", "./node_modules/tns-core-modules/*", ] } } } I think this is a better solution than the one i had before!

Thank you :)

Thomas

PeterStaev commented 5 years ago

Thanks for sharing your experience! Since I'm not using {N} in shared web projects, had no idea that how things are working there 😃