@@ -98,6 +98,41 @@ exports.getConvertedExternals = (externals) => {
9898 return modifiedExternals ;
9999} ;
100100
101+
102+ /**
103+ * The `require.context` call in `bundle-config-loader` will ask the FS for files and
104+ * the PlatformFSPlugin will return files without `.${platform}`. The SplitChunksPlugin will
105+ * compare the `appComponents` with the files returned from the `PlatformFSPlugin` and when they
106+ * do not match because of the platform extension, it will duplicate the custom components
107+ * in `bundle` (activity.js - included by the `require.context` call in `bundle-config-loader`)
108+ * and `vendor` (activity.android.js - included by `android-app-components-loader` and `SplitChunksPlugin`).
109+ * We are post-processing the `appComponents` in order to unify the file names and avoid getting
110+ * a build-time SBG exception for duplicate native class definition.
111+ */
112+ exports . processAppComponents = ( appComponents , platform ) => {
113+ for ( const key in appComponents ) {
114+ appComponents [ key ] = appComponents [ key ] . replace ( `.${ platform } ` , "" ) ;
115+ }
116+ } ;
117+
118+ /**
119+ * The `bundle-config-loader` needs this in order to skip the custom entries in its `require.context` call.
120+ * If we don't skip them, custom entries like custom Android application will be included in both `application.js`
121+ * (because its defined as an entry) and `bundle.js` (included by the `require.context` call in `bundle-config-loader`)
122+ * causing a build-time SBG exception for duplicate native class definition.
123+ * We are removing the extension in order to unify the file names with the `PlatformFSPlugin`.
124+ */
125+ exports . getUserDefinedEntries = ( entries , platform ) => {
126+ const userDefinedEntries = [ ] ;
127+ for ( const entry in entries ) {
128+ if ( entry !== "bundle" && entry !== "tns_modules/tns-core-modules/inspector_modules" ) {
129+ userDefinedEntries . push ( entries [ entry ] . replace ( `.${ platform } ` , "" ) ) ;
130+ }
131+ }
132+
133+ return userDefinedEntries ;
134+ } ;
135+
101136const sanitize = name => name
102137 . split ( "" )
103138 . filter ( char => / [ a - z A - Z 0 - 9 ] / . test ( char ) )
0 commit comments