{"id":15067182,"url":"https://github.com/leegeunhyeok/swc-plugin-react-native-esbuild-module","last_synced_at":"2025-10-05T04:31:43.043Z","repository":{"id":206349760,"uuid":"716420625","full_name":"leegeunhyeok/swc-plugin-react-native-esbuild-module","owner":"leegeunhyeok","description":"Custom module plugin for `@react-native-esbuild` (Deprecated)","archived":true,"fork":false,"pushed_at":"2023-11-19T06:31:03.000Z","size":88,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-30T16:26:44.254Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leegeunhyeok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-09T05:12:20.000Z","updated_at":"2023-11-19T07:03:38.000Z","dependencies_parsed_at":"2024-09-29T11:41:46.174Z","dependency_job_id":"a8f0b44c-c11a-49e7-88b3-7cb9be757349","html_url":"https://github.com/leegeunhyeok/swc-plugin-react-native-esbuild-module","commit_stats":null,"previous_names":["leegeunhyeok/swc-plugin-react-native-esbuild-module"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leegeunhyeok%2Fswc-plugin-react-native-esbuild-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leegeunhyeok%2Fswc-plugin-react-native-esbuild-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leegeunhyeok%2Fswc-plugin-react-native-esbuild-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leegeunhyeok%2Fswc-plugin-react-native-esbuild-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leegeunhyeok","download_url":"https://codeload.github.com/leegeunhyeok/swc-plugin-react-native-esbuild-module/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235364856,"owners_count":18978252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-25T01:17:42.320Z","updated_at":"2025-10-05T04:31:37.713Z","avatar_url":"https://github.com/leegeunhyeok.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-esbuild-module-plugin\n\n\u003e [!WARNING]\n\u003e THIS PACKAGE IS DEPRECATED. USE [swc-plugin-global-esm](https://github.com/leegeunhyeok/swc-plugin-global-esm) INSTEAD.\n\nTransform module imports statement for [@react-native-esbuild](https://github.com/leegeunhyeok/react-native-esbuild)'s custom module system.\n\n\u003e [!WARNING]\n\u003e This plugin is for custom module system to implement Hot Module Replacement(HMR) in some bundlers that don't support it.\n\n## Installation\n\n```bash\nnpm install react-native-esbuild-module-plugin\n# or yarn\nyarn add react-native-esbuild-module-plugin\n```\n\n## Usage\n\nInject global module manager to top of bundle.\n\n```js\n!((global) =\u003e {\n  const __m: {};\n  global.__modules = {\n    import(moduleName) {\n      return (\n        __m[moduleName] ||\n        (() =\u003e {\n          throw new Error(`\"${moduleName}\" module not found`);\n        })()\n      );\n    },\n    export(moduleName, exports) {\n      return __m[moduleName] = exports;\n    },\n  };\n})(\n  typeof globalThis !== 'undefined'\n    ? globalThis\n    : typeof global !== 'undefined'\n    ? global\n    : typeof window !== 'undefined'\n    ? window\n    : this,\n);\n```\n\nand add plugin to your swc options.\n\n```ts\nimport { transform } from '@swc/core';\n\nawait transform(code, {\n  jsc: {\n    experimental: {\n      plugins: [\n        // Add plugin here.\n        ['react-native-esbuild-module-plugin', {\n          // Convert import statements to custom module system and remove export statements\n          // Defaults to `false`\n          runtimeModule: true,\n        }],\n      ],\n    },\n    externalHelpers: false, // You should disable external helpers when runtimeModule is `true`\n  },\n});\n```\n\n## Preview\n\nBefore\n\n```ts\nimport React, { useState, useEffect } from 'react';\nimport { Container, Section, Button, Text } from '@app/components';\nimport { useCustomHook } from '@app/hooks';\nimport * as app from '@app/core';\n\nexport function MyComponent (): JSX.Element {\n  // ...\n}\n\n// anonymous class\nexport default class {}\n```\n\nAfter\n\n```js\n// with `runtimeModule: true`\nvar React = global.__modules.import(\"react\").default;\nvar useState = global.__modules.import(\"react\").useState;\nvar useEffect = global.__modules.import(\"react\").useEffect;\nvar Container = global.__modules.import(\"@app/components\").Container;\nvar Section = global.__modules.import(\"@app/components\").Section;\nvar Button = global.__modules.import(\"@app/components\").Button;\nvar Text = global.__modules.import(\"@app/components\").Text;\nvar useCustomHook = global.__modules.import(\"@app/hooks\").useCustomHook;\nvar app = global.__modules.import(\"@app/core\");\n\nfunction MyComponent () {\n  // ...\n}\n\nvar __export_default = class {}\n\nglobal.__modules.export(\"\u003cmodule-file-name\u003e\", {\n  \"MyComponent\": MyComponent,\n  \"default\": __export_default\n});\n```\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleegeunhyeok%2Fswc-plugin-react-native-esbuild-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleegeunhyeok%2Fswc-plugin-react-native-esbuild-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleegeunhyeok%2Fswc-plugin-react-native-esbuild-module/lists"}