Skip to content

generating bundle of MiniApp stuck at minify the code instead using hermes obfuscate #1322

@flixyudh

Description

@flixyudh

Describe the bug

I'm creating a MiniApp with this config

import path from 'node:path';
import {fileURLToPath} from 'node:url';
import * as Repack from '@callstack/repack';
import rspack from '@rspack/core';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

/**
 * Rspack configuration enhanced with Re.Pack defaults for React Native.
 *
 * Learn about Rspack configuration: https://rspack.dev/config/
 * Learn about Re.Pack configuration: https://re-pack.dev/docs/guides/configuration
 */

export default Repack.defineRspackConfig((param) => {
  console.log("📁�[1;97;46m�[4m�[3mpackages/MiniApp/rspack.config.mjs:17�[0m📁\n","💁  ℹ️ param >>> ", param)
  const { mode, platform, ...rest } = param;

  return {
    mode,
    context: __dirname,
    entry: {},
    resolve: {
      ...Repack.getResolveOptions(),
    },
    output: {
      uniqueName: 'sas-mini-app',
    },
    module: {
      rules: [
        {
          test: /\.[cm]?[jt]sx?$/,
          type: 'javascript/auto',
          use: {
            loader: '@callstack/repack/babel-swc-loader',
            parallel: true,
            options: {},
          },
        },
        ...Repack.getAssetTransformRules({inline:true}),
      ],
    },
    plugins: [
      new Repack.RepackPlugin(),
      new Repack.plugins.HermesBytecodePlugin({
        enabled: mode === 'production',
        test: /\.(js)?bundle$/,
        exclude: /index.bundle$/,
      }),
      new Repack.plugins.ModuleFederationPluginV2({
        name: 'MiniApp',
        filename: 'miniapp.container.js.bundle',
        dts: false,
        exposes: {
          './App': './src/navigation/MainNavigator',
        },
        shared: {
          react: { singleton: true, eager: true, requiredVersion: '19.2.0' },
          'react-native': {
            singleton: true,
            eager: true,
            requiredVersion: '0.83.1',
          },
          '@react-navigation/native': {
            singleton: true,
            eager: true,
            requiredVersion: '6.1.18',
          },
          '@react-navigation/native-stack': {
            singleton: true,
            eager: true,
            requiredVersion: '6.11.0',
          },
          'react-native-safe-area-context': {
            singleton: true,
            eager: true,
            requiredVersion: '^5.6.2',
          },
          'react-native-screens': {
            singleton: true,
            eager: true,
            requiredVersion: '^4.19.0',
          },
        },
      }),
      // silence missing @react-native-masked-view optionally required by @react-navigation/elements
      new rspack.IgnorePlugin({
        resourceRegExp: /^@react-native-masked-view/,
      }),
    ],
  };
});

but when I run yarn bundle:ios (react-native bundle --platform ios --entry-file index.js --dev false), the bundle only minify. Is it expected result?

output yarn bundle:ios :

(node:18123) [DEP0155] DeprecationWarning: Use of deprecated trailing slash pattern mapping "./" in the "exports" field module resolution of the package at /Users/165536.yudi/Documents/Personal/SandboxPlayground/Flix2/node_modules/react-native/package.json. Mapping specifiers ending in "/" is no longer supported.
(Use `node --trace-deprecation ...` to show where the warning was created)
Writing compiler stats
ℹ [09:34:19.231Z][LoggerPlugin] assets by path *.bundle 2.48 MiB
  asset index.bundle 1.3 MiB [emitted] [minimized] (name: main)
  asset miniapp.container.js.bundle 1.06 MiB [emitted] [minimized] (name: MiniApp)
  asset __federation_expose_App.chunk.bundle 123 KiB [emitted] [minimized] (name: __federation_expose_App)
assets by path *.json 23.2 KiB
  asset mf-stats.json 12.1 KiB [emitted]
  asset mf-manifest.json 11.1 KiB [emitted]
runtime modules 34.1 KiB 27 modules
modules by path ../../node_modules/ 3.16 MiB 731 modules
provide-module modules 966 bytes 23 modules
consume-shared-module modules 966 bytes
  modules by path consume shared module (default) react-native/ 546 bytes 13 modules
  modules by path consume shared module (default) @react-native/ 168 bytes 4 modules
  modules by path consume shared module (default) @react-navigation/ 84 bytes 2 modules
  + 4 modules
modules by path ./ 128 KiB
  modules by path ./src/screens/*.tsx 5.03 KiB 2 modules
  modules by path ./src/components/Button/ 1.57 KiB 2 modules
  + 5 modules
@module-federation/runtime/rspack.js!=!data:text/javascript,import __module_.. 14.6 KiB [built] [code generated]
container entry 42 bytes (javascript) 42 bytes (expose) [built] [code generated]
ios (Rspack 1.6.8) compiled successfully in 3.85 s

System Info

-

Re.Pack Version

^5.2.3

Reproduction

https://github.com/flixyudh/RN-MF/

Steps to reproduce

  1. yarn install
  2. cd packages/MiniApp
  3. yarn bundle:ios

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:newNew issue, not reviewed by the team yet.type:bugA bug report.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions