@hero-design/rn 0.0.0-mainIsReactNative.4 → 0.0.0-mainIsReactNative.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "0.0.0-mainIsReactNative.4",
3
+ "version": "0.0.0-mainIsReactNative.6",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,8 +20,7 @@
20
20
  "build:types": "tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json",
21
21
  "build": "yarn build:js && yarn build:types",
22
22
  "build:watch": "yarn build:js -w & yarn build:types -w",
23
- "publish:npm": "yarn publish --access public",
24
- "set-dev-env": "npm pkg set react-native=src/index.ts"
23
+ "publish:npm": "yarn publish --access public"
25
24
  },
26
25
  "dependencies": {
27
26
  "@emotion/native": "^11.11.0",
package/rollup.config.mjs CHANGED
@@ -8,9 +8,35 @@ import copy from 'rollup-plugin-copy';
8
8
  import flow from 'rollup-plugin-flow';
9
9
  import { visualizer } from 'rollup-plugin-visualizer';
10
10
  import glob from 'glob';
11
- import { fileURLToPath } from 'node:url';
11
+ import { fileURLToPath, pathToFileURL } from 'node:url';
12
+ import { readFileSync } from 'node:fs';
13
+ import { createRequire } from 'node:module';
12
14
  import pkg from './package.json' with { type: 'json' };
13
15
 
16
+ const require = createRequire(import.meta.url);
17
+
18
+ // Inline hero-editor/dist/app.js as a string literal so it can be injected
19
+ // into a WebView without triggering browser-only APIs at module init time.
20
+ const inlineHeroEditorApp = () => ({
21
+ name: 'inline-hero-editor-app',
22
+ resolveId(id) {
23
+ if (id === 'hero-editor/dist/app.js') {
24
+ return pathToFileURL(require.resolve('hero-editor/dist/app.js')).href;
25
+ }
26
+ return null;
27
+ },
28
+ load(id) {
29
+ if (!id.includes('hero-editor/dist/app.js')) return null;
30
+ try {
31
+ const filePath = id.startsWith('file://') ? fileURLToPath(id) : id;
32
+ const content = readFileSync(filePath, 'utf8');
33
+ return `export default ${JSON.stringify(content)};`;
34
+ } catch {
35
+ return null;
36
+ }
37
+ },
38
+ });
39
+
14
40
  const extensions = ['.js', '.jsx', '.ts', '.tsx'];
15
41
 
16
42
  const generateBuildStats = process.env.GENERATE_BUILD_STATS === 'true';
@@ -49,11 +75,12 @@ export default [
49
75
  'react-native-safe-area-context',
50
76
  'react-native-svg',
51
77
  'react-native-vector-icons',
52
- 'react-native-webview',
53
- "hero-editor"
78
+ 'react-native-webview'
54
79
  ],
55
80
  plugins: [
81
+ inlineHeroEditorApp(),
56
82
  replace({
83
+ preventAssignment: true,
57
84
  'process.env.NODE_ENV': JSON.stringify('production'),
58
85
  }),
59
86
  nodeResolve({ extensions, browser: false }),
@@ -1,3 +1,3 @@
1
- import * as heroEditorApp from 'hero-editor/dist/app.js';
1
+ import heroEditorApp from 'hero-editor/dist/app.js';
2
2
 
3
3
  export default heroEditorApp;
@@ -1,2 +1,2 @@
1
- import * as heroEditorApp from 'hero-editor/dist/app.js';
1
+ import heroEditorApp from 'hero-editor/dist/app.js';
2
2
  export default heroEditorApp;