Meteor 3.4 + rspack: Cordova builds appear not to include client entry point JavaScript code

Hi, Me and Claude have struggled to get a cordova build to work on my android device (all good for the web app…eventually). It seems like the entry app code is simply not getting invoked.

Any ideas? Here’s what Claude thinks might be relevant:

Description:

  • Meteor 3.4 with rspack integration and “modern”: true
  • Cordova Android builds bundle HTML templates but not the client/main.js entry point code
  • The auto-generated client-meteor.js in the Cordova bundle only has template imports, no actual application JavaScript
  • This causes the app to load but never execute any application code
  • mainModule is correctly configured in package.json but ignored for web.cordova architecture

To Reproduce:

  1. Create a Meteor 3.4 project with rspack and “modern”: true
  2. Add mainModule config to package.json
  3. Build for Cordova: meteor run android-device
  4. Check .meteor/local/cordova-build/www/application/app/app.js - client/main.js code is missing

Expected: The bundled app.js should include the rspack-generated JavaScript code from client/main.js

Actual: Only HTML templates are bundled, no application JavaScript code

And further, my Rspack.config.js reads:

const { defineConfig } = require('@meteorjs/rspack');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

/**
 * Rspack configuration for Meteor projects.
 *
 * Provides typed flags on the `Meteor` object, such as:
 * - `Meteor.isClient` / `Meteor.isServer`
 * - `Meteor.isDevelopment` / `Meteor.isProduction`
 * - …and other flags available
 *
 * Use these flags to adjust your build settings based on environment.
 */
module.exports = defineConfig(Meteor => {
  const config = {
    devtool: Meteor.isDevelopment ? 'cheap-module-source-map' : false,
    module: {
      rules: [
        {
          test: /\.scss$/,
          use: [
            {
              loader: 'sass-loader',
              options: {
                // Dart Sass
                implementation: require('sass'),
                sourceMap: Meteor.isDevelopment,
                sassOptions: {
                  // Suppress deprecation warnings from Bootstrap Sass and other legacy SCSS
                  silenceDeprecations: [
                    'import',           // @import rules
                    'slash-div',        // / division operator
                    'color-functions',  // lighten(), darken(), etc.
                    'global-builtin',   // Global built-in functions
                    'if-function',      // if() function syntax
                  ],
                },
              },
            },
          ],
          type: 'css',
        },
      ],
    },
    plugins: [
      // Add Node.js polyfills for browser builds
      ...(Meteor.isClient ? [new NodePolyfillPlugin()] : []),
      // Bundle analyzer - run with RSDOCTOR=true meteor
      ...(process.env.RSDOCTOR && Meteor.isClient ? [
        new (require('@rsdoctor/rspack-plugin').RsdoctorRspackPlugin)()
      ] : []),
    ],
    resolve: {
      fallback: Meteor.isClient ? {
        crypto: require.resolve('crypto-browserify'),
        stream: require.resolve('stream-browserify'),
        buffer: require.resolve('buffer/'),
      } : {},
    },
  };

  // Enable HMR in development
  if (Meteor.isDevelopment && Meteor.isClient) {
    config.devServer = {
      hot: true,
    };
  }

  // Add server-specific externals for native modules
  if (Meteor.isServer) {
    // Use function-based externals for more control
    config.externals = [
      function({ request }, callback) {
        // Externalize zlib-sync and any .node files
        if (request === 'zlib-sync' || /\.node$/.test(request)) {
          return callback(null, 'commonjs ' + request);
        }
        callback();
      }
    ];
  }

  return config;
});

Weird. I tested the Cordova scenarios myself through the betas and they worked well.

Do you get a white screen? Is nothing rendered?

Could you share a repository that mimics the project you’re working on, with the issue happening? Since you provided a custom rspack.config.js, I’d like a reproduction that’s as close as possible. I’ll try your steps and see what happens, but an exact reproduction would work best to iterate the understanding of all edges and fix later if needed.

I just tested it, and Cordova works well with the Rspack integration. I used the minimal React skeleton for the test.

Regarding the expectation, I now get what you mean, and Claude is wrong on that expectation. In Meteor 3.4, the app code is precompiled by Rspack, so client/main.js entrypoint is not expected to appear there. Instead, you see the final output in app.js. This behavior is preserved from previous versions.

As shown in the picture below, I used an app in Meteor 3.3.2 (without Rspack) and another in 3.4 (with Rspack), and the client entrypoint never appear nor any of the source code. That is not the expected behavior. The app code from the entrypoint is still present, but compiled into the app.js single file within the Cordova app context (I highlighted ‘Learn Meteor!’ within that file so it’s easy to spot).

If your app doesn’t load when using Meteor Rspack in 3.4, the reason may be something else. We’d need more info and a way to reproduce it. If you can share a reproducible repository, we can help investigate.

1 Like

Many thanks - I will investigate further based on your useful feedback and revert