Skip to content

Can't build app if both itself and its dependency have a dependency on tns-core-modules #4469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shirakaba opened this issue Mar 23, 2019 · 4 comments
Labels

Comments

@shirakaba
Copy link

shirakaba commented Mar 23, 2019

Environment

  • CLI: 5.2.4
  • Cross-platform modules: 5.2.2
  • Android Runtime: 5.2.1
  • iOS Runtime: 5.2.0
  • Plugin(s): none

Describe the bug

I'm making a React renderer for NativeScript (try to stay calm). It depends upon tns-core-modules. However, when I install this React renderer as a dependency of a sample app, when building the sample app (whether with or without the --bundle flag), Xcode finds duplicates of tns-core-modules and thus tns-core-modules-widgets. This could be related to the webpack config (which is using the defaults from tns create sample --tsc)..?

# Where 'sample' is the app that consumes the React renderer library 
cd sample
tns run ios --clean

Typescript typings conflicts:

Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Searching for devices...
Found peer TypeScript 3.1.6
../react-nativescript/node_modules/tns-core-modules/module.d.ts(69,5): error TS2300: Duplicate identifier 'markup'.
../react-nativescript/node_modules/tns-core-modules/module.d.ts(70,5): error TS2300: Duplicate identifier 'script'.
../react-nativescript/node_modules/tns-core-modules/module.d.ts(71,5): error TS2300: Duplicate identifier 'style'.
../react-nativescript/node_modules/tns-core-modules/tns-core-modules.d.ts(4,1): error TS6200: Definitions of the following identifiers conflict with those in another file: "audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import", "internal", "location", "manifest", "object", "ping", "plugin", "prefetch", "script", "serviceworker", "sharedworker", "subresource", "style", "track", "video", "worker", "xmlhttprequest", "xslt", HeaderInit, WeakRef
../react-nativescript/node_modules/tns-core-modules/tns-core-modules.d.ts(5,5): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.
node_modules/tns-core-modules/module.d.ts(69,5): error TS2300: Duplicate identifier 'markup'.
node_modules/tns-core-modules/module.d.ts(70,5): error TS2300: Duplicate identifier 'script'.
node_modules/tns-core-modules/module.d.ts(71,5): error TS2300: Duplicate identifier 'style'.
node_modules/tns-core-modules/tns-core-modules.d.ts(4,1): error TS6200: Definitions of the following identifiers conflict with those in another file: "audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import", "internal", "location", "manifest", "object", "ping", "plugin", "prefetch", "script", "serviceworker", "sharedworker", "subresource", "style", "track", "video", "worker", "xmlhttprequest", "xslt", HeaderInit, WeakRef

Frameworks from tns-core-modules (e.g. TNSWidgets.framework) are referenced from both the consumer project and the library.

Xcode build...
error: unexpected duplicate task: CodeSign /Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework (in target 'sample')
error: unexpected duplicate task: CodeSign /Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework (in target 'sample')
error: Multiple commands produce '/Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework':
1) Target 'sample' has copy command from '/Users/jamie/Documents/git/react-nativescript/sample/node_modules/react-nativescript/node_modules/tns-core-modules-widgets/platforms/ios/TNSWidgets.framework' to '/Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework'
2) Target 'sample' has copy command from '/Users/jamie/Documents/git/react-nativescript/sample/node_modules/tns-core-modules-widgets/platforms/ios/TNSWidgets.framework' to '/Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework'
error: Multiple commands produce '/Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework/TNSWidgets':
1) Target 'sample' has copy command from '/Users/jamie/Documents/git/react-nativescript/sample/node_modules/react-nativescript/node_modules/tns-core-modules-widgets/platforms/ios/TNSWidgets.framework' to '/Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework'
2) Target 'sample' has copy command from '/Users/jamie/Documents/git/react-nativescript/sample/node_modules/tns-core-modules-widgets/platforms/ios/TNSWidgets.framework' to '/Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework'
warning: duplicate output file '/Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework' on task: PBXCp /Users/jamie/Documents/git/react-nativescript/sample/node_modules/tns-core-modules-widgets/platforms/ios/TNSWidgets.framework /Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework (in target 'sample')
warning: duplicate output file '/Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework/TNSWidgets' on task: PBXCp /Users/jamie/Documents/git/react-nativescript/sample/node_modules/tns-core-modules-widgets/platforms/ios/TNSWidgets.framework /Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework (in target 'sample')
warning: duplicate output file '' on task: PBXCp /Users/jamie/Documents/git/react-nativescript/sample/node_modules/tns-core-modules-widgets/platforms/ios/TNSWidgets.framework /Users/jamie/Documents/git/react-nativescript/sample/platforms/ios/build/Debug-iphonesimulator/sample.app/Frameworks/TNSWidgets.framework (in target 'sample')
note: Using new build systemnote: Planning buildnote: Constructing build description
** BUILD FAILED **

Unable to apply changes on device: A77F52A9-0201-47A7-8523-1F7C0CFBD57C. Error is: Command xcodebuild failed with exit code 65.

To Reproduce

  1. Create a library that depends on tns-core-modules
  2. Create an app that installs that library, and also depends upon (the same) version of tns-core-modules

Expected behavior

App is supposed to build correctly.

Sample project

https://github.com/shirakaba/react-nativescript

Additional context

npm dedupe gets things working, but does also remove all the duplicate dependencies in your library folder, preventing you from developing your library.

npm ls
# Lots of unrelated packages
├─┬ [email protected] -> /Users/jamie/Documents/git/react-nativescript/react-nativescript
│ ├── @types/[email protected] extraneous
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected] deduped
│ │ │ ├── [email protected] deduped
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │   ├── [email protected] deduped
│ │   └── [email protected] deduped
│ ├─┬ [email protected]
│ │ ├── [email protected] deduped
│ │ ├── [email protected] deduped
│ │ ├── [email protected] deduped
│ │ └── [email protected] deduped
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected] extraneous
└─┬ [email protected]
  ├── [email protected]
  └── [email protected]

Note how tns-core-modules-widgets appears twice.

Related issues

@NickIliev
Copy link
Contributor

@shirakaba in the plugin source remove the tns-core-modules from the dependency list. You could install the tns-core-modules as a devDepedency (e.g. as done here) and that won't prevent you from accessing the tns-core-modules in your plugin code (e.g. as done here) as each NativeScript project would have the tns-core-modules installed in the end (e.g. your demo called sample is installing tns-core-modules as dependency).

@shirakaba
Copy link
Author

Fantastic, that works!

I've applied your suggested fix in commit 92682e3 of my repo.

@NickIliev
Copy link
Contributor

@shirakaba glad to hear you are able to move forward! As a side note I've read your roadmap and noticed that you need TSX support so perhaps you could refer to this plugin for inspiration.

@shirakaba
Copy link
Author

shirakaba commented Mar 25, 2019

@NickIliev That's invaluable, thank you! I'll add that as a note in the repo.

Before I can get as far as TSX, I'll first need to figure out how to bootstrap the app. I'll file this issue that I'm blocked on under the NativeScript main repository in a moment; would be glad of any help with that, as well!

EDIT: it's more of a question than a bug, so I've submitted it to StackOverflow instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants