Environment
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
tns-core-modulestns-core-modulesExpected 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
@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).
Fantastic, that works!
I've applied your suggested fix in commit 92682e3 of my repo.
@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.
@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.