@granite-js/plugin-core 0.1.34 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -1,229 +1,18 @@
1
1
  # @granite-js/plugin-core
2
2
 
3
- ## 0.1.34
3
+ ## 1.0.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 9c39997: bump version up `@swc/core`
8
- - @granite-js/utils@0.1.34
7
+ - @granite-js/utils@1.0.1
9
8
 
10
- ## 0.1.33
9
+ ## 1.0.0
11
10
 
12
- ### Patch Changes
13
-
14
- - @granite-js/utils@0.1.33
15
-
16
- ## 0.1.32
17
-
18
- ### Patch Changes
19
-
20
- - 7572713: bump version up babel
21
- - @granite-js/utils@0.1.32
22
-
23
- ## 0.1.31
24
-
25
- ### Patch Changes
26
-
27
- - 9bf8b50: expose resolveRequest option
28
- - e957833: expose `resolver.resolverMainFields` and `resolver.unstable_conditionNames` options
29
- - @granite-js/utils@0.1.31
30
-
31
- ## 0.1.30
32
-
33
- ### Patch Changes
34
-
35
- - @granite-js/utils@0.1.30
36
-
37
- ## 0.1.29
38
-
39
- ### Patch Changes
40
-
41
- - ed4cdbf: support additional metro config options from granite.config.ts
42
- - @granite-js/utils@0.1.29
43
-
44
- ## 0.1.28
45
-
46
- ### Patch Changes
47
-
48
- - 1d958cc: ci: provenance
49
- - Updated dependencies [1d958cc]
50
- - @granite-js/utils@0.1.28
51
-
52
- ## 0.1.27
53
-
54
- ### Patch Changes
55
-
56
- - e32b020: ci: oidc
57
- - Updated dependencies [e32b020]
58
- - @granite-js/utils@0.1.27
59
-
60
- ## 0.1.26
61
-
62
- ### Patch Changes
63
-
64
- - @granite-js/utils@0.1.26
65
-
66
- ## 0.1.25
67
-
68
- ### Patch Changes
69
-
70
- - @granite-js/utils@0.1.25
71
-
72
- ## 0.1.24
73
-
74
- ### Patch Changes
75
-
76
- - 6e42c3d: add inspectorProxy options
77
- - @granite-js/utils@0.1.24
78
-
79
- ## 0.1.23
80
-
81
- ### Patch Changes
82
-
83
- - @granite-js/utils@0.1.23
84
-
85
- ## 0.1.22
86
-
87
- ### Patch Changes
88
-
89
- - @granite-js/utils@0.1.22
90
-
91
- ## 0.1.21
92
-
93
- ### Patch Changes
94
-
95
- - @granite-js/utils@0.1.21
96
-
97
- ## 0.1.20
98
-
99
- ### Patch Changes
100
-
101
- - @granite-js/utils@0.1.20
102
-
103
- ## 0.1.19
104
-
105
- ### Patch Changes
106
-
107
- - e9a3daf: missing Metro configuration compatibility
108
- - @granite-js/utils@0.1.19
109
-
110
- ## 0.1.18
111
-
112
- ### Patch Changes
113
-
114
- - @granite-js/utils@0.1.18
115
-
116
- ## 0.1.17
117
-
118
- ### Patch Changes
119
-
120
- - 9c415df: supports dynamic plugin config
121
- - @granite-js/utils@0.1.17
122
-
123
- ## 0.1.16
124
-
125
- ### Patch Changes
126
-
127
- - @granite-js/utils@0.1.16
128
-
129
- ## 0.1.15
130
-
131
- ### Patch Changes
132
-
133
- - d16ee87: Add useInitialProps, useInitialSearchParams hook.
134
- - Updated dependencies [d16ee87]
135
- - @granite-js/utils@0.1.15
136
-
137
- ## 0.1.14
138
-
139
- ### Patch Changes
140
-
141
- - @granite-js/utils@0.1.14
142
-
143
- ## 0.1.13
144
-
145
- ### Patch Changes
146
-
147
- - @granite-js/utils@0.1.13
148
-
149
- ## 0.1.12
150
-
151
- ### Patch Changes
152
-
153
- - d1e6585: fix module resolutions
154
- - 1e99fe1: support initialScheme, support host
155
- - Updated dependencies [d1e6585]
156
- - @granite-js/utils@0.1.12
157
-
158
- ## 0.1.11
159
-
160
- ### Patch Changes
161
-
162
- - d3a2b58: improve resolver plugin
163
- - @granite-js/utils@0.1.11
164
-
165
- ## 0.1.10
166
-
167
- ### Patch Changes
168
-
169
- - 9438be5: add dynamic config support
170
- - @granite-js/utils@0.1.10
171
-
172
- ## 0.1.9
173
-
174
- ### Patch Changes
175
-
176
- - 935bb36: fix `BuildUtils` errors and incorrect plugin types
177
-
178
- ## 0.1.8
179
-
180
- ### Patch Changes
181
-
182
- - b69366c: improve config structure
183
-
184
- ## 0.1.7
185
-
186
- ## 0.1.6
187
-
188
- ## 0.1.5
189
-
190
- ## 0.1.4
191
-
192
- ## 0.1.3
193
-
194
- ## 0.1.2
195
-
196
- ## 0.1.1
197
-
198
- ### Patch Changes
199
-
200
- - d675415: Improve scaffolding to provide a better showcase UI
201
- - 10a5f3f: empty
202
-
203
- ## 0.1.0
204
-
205
- ### Minor Changes
206
-
207
- - 561a3ed: fix: docs deadlink
208
-
209
- ## 0.0.3
210
-
211
- ### Patch Changes
212
-
213
- - ed4d356: changeset
11
+ ### Major Changes
214
12
 
215
- ## 0.0.2
13
+ - 260daab: feat: introduce support react native 0.84
216
14
 
217
15
  ### Patch Changes
218
16
 
219
- - 0ae09b7: deploy guide
220
- - 0ae09b7: type fix
221
- - 0ae09b7: guide
222
- - 0ae09b7: showcase
223
- - 0ae09b7: refactor interface names
224
- - 0ae09b7: plugin-router
225
- - 0ae09b7: CanGoBackGuard 수정, typecheck fix, lint fix
226
- - 0ae09b7: counter
227
- - 0ae09b7: licenses
228
- - 0ae09b7: - Add plugin context to allow plugins to share data
229
- - Implement Hermes plugin to compile Hermes bytecode and compose source maps
17
+ - Updated dependencies [260daab]
18
+ - @granite-js/utils@1.0.0
package/dist/index.cjs CHANGED
@@ -1,4 +1,5 @@
1
- //#region rolldown:runtime
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6,12 +7,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
9
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
15
20
  }
16
21
  return to;
17
22
  };
@@ -24,7 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
29
  let es_toolkit = require("es-toolkit");
25
30
  let path = require("path");
26
31
  path = __toESM(path);
27
- let __granite_js_utils = require("@granite-js/utils");
32
+ let _granite_js_utils = require("@granite-js/utils");
28
33
  let fs = require("fs");
29
34
  fs = __toESM(fs);
30
35
  let zod = require("zod");
@@ -256,7 +261,8 @@ async function mergeConfig(base, ...configs) {
256
261
  swc: mergeSwc(resolvedAcc?.swc, resolvedCurr?.swc),
257
262
  devServer: mergeDevServer(resolvedAcc?.devServer, resolvedCurr?.devServer),
258
263
  metro: mergeMetro(resolvedAcc?.metro, resolvedCurr?.metro),
259
- extra: mergeExtra(resolvedAcc?.extra, resolvedCurr?.extra)
264
+ extra: mergeExtra(resolvedAcc?.extra, resolvedCurr?.extra),
265
+ reactNativePath: resolvedCurr.reactNativePath ?? resolvedAcc.reactNativePath
260
266
  };
261
267
  }, resolveDynamicConfig(base));
262
268
  }
@@ -351,6 +357,7 @@ async function resolveConfig(config) {
351
357
  function resolveMetroConfig(pluginConfig) {
352
358
  return {
353
359
  ...pluginConfig.metro ?? {},
360
+ reactNativePath: pluginConfig.reactNativePath,
354
361
  babelConfig: pluginConfig.babel,
355
362
  transformSync: pluginConfig?.transformer?.transformSync
356
363
  };
@@ -367,8 +374,8 @@ function prepareGraniteGlobalsScript(config) {
367
374
  }
368
375
  function writeGraniteGlobalsScript(config) {
369
376
  const script = getGraniteGlobalScript(config);
370
- const filePath = path.default.join((0, __granite_js_utils.getLocalTempDirectoryPath)(config.rootDir), "granite-globals.js");
371
- (0, __granite_js_utils.prepareLocalDirectory)(config.rootDir);
377
+ const filePath = path.default.join((0, _granite_js_utils.getLocalTempDirectoryPath)(config.rootDir), "granite-globals.js");
378
+ (0, _granite_js_utils.prepareLocalDirectory)(config.rootDir);
372
379
  fs.default.writeFileSync(filePath, script, "utf-8");
373
380
  return filePath;
374
381
  }
@@ -388,7 +395,8 @@ const pluginConfigSchema = zod.object({
388
395
  build: zod.custom().optional(),
389
396
  devServer: zod.custom().optional(),
390
397
  metro: zod.custom().optional(),
391
- plugins: zod.custom()
398
+ plugins: zod.custom(),
399
+ reactNativePath: zod.string().optional()
392
400
  });
393
401
 
394
402
  //#endregion
@@ -418,6 +426,7 @@ const pluginConfigSchema = zod.object({
418
426
  * @param config.metro - Configure Metro bundler settings
419
427
  * @param config.devServer - Configure Mpack dev server settings
420
428
  * @param config.plugins - Granite plugins to enhance functionality
429
+ * @param config.reactNativePath - Path to `react-native` directory (defaults to project's `react-native` package path)
421
430
  * @returns The processed configuration
422
431
  *
423
432
  * @example
@@ -446,7 +455,7 @@ const pluginConfigSchema = zod.object({
446
455
  */
447
456
  const defineConfig = async (config) => {
448
457
  const parsed = pluginConfigSchema.parse(config);
449
- const cwd = parsed.cwd ?? (0, __granite_js_utils.getPackageRoot)();
458
+ const cwd = parsed.cwd ?? (0, _granite_js_utils.getPackageRoot)();
450
459
  const appName = parsed.appName;
451
460
  const host = parsed.host ?? "";
452
461
  const scheme = parsed.scheme;
@@ -476,7 +485,8 @@ const defineConfig = async (config) => {
476
485
  host
477
486
  }),
478
487
  ...configs
479
- ].filter(es_toolkit.isNotNil)
488
+ ].filter(es_toolkit.isNotNil),
489
+ reactNativePath: parsed.reactNativePath
480
490
  };
481
491
  };
482
492
 
@@ -485,7 +495,7 @@ const defineConfig = async (config) => {
485
495
  const MODULE_NAME = "granite";
486
496
  const loadConfig = async (options = {}) => {
487
497
  let result;
488
- const resolveRoot = options.root ?? (0, __granite_js_utils.getPackageRoot)();
498
+ const resolveRoot = options.root ?? (0, _granite_js_utils.getPackageRoot)();
489
499
  if (options.configFile) result = await getConfigExplorer().load(path.default.resolve(resolveRoot, options.configFile));
490
500
  else result = await getConfigExplorer({ searchPlaces: [
491
501
  `${MODULE_NAME}.config.ts`,
package/dist/index.d.cts CHANGED
@@ -73,6 +73,10 @@ interface BuildConfig {
73
73
  * ```
74
74
  */
75
75
  extra?: any;
76
+ /**
77
+ * Path to `react-native` package path
78
+ */
79
+ reactNativePath?: string;
76
80
  }
77
81
  interface ResolverConfig {
78
82
  /**
@@ -487,6 +491,7 @@ interface AdditionalMetroConfig extends MetroConfig {
487
491
  babelConfig?: babel.TransformOptions;
488
492
  transformSync?: (id: string, code: string) => string;
489
493
  projectRoot?: MetroConfig['projectRoot'];
494
+ reactNativePath?: string;
490
495
  }
491
496
  //#endregion
492
497
  //#region src/types/GranitePlugin.d.ts
@@ -597,6 +602,7 @@ declare const pluginConfigSchema: z.ZodObject<{
597
602
  devServer: z.ZodOptional<z.ZodCustom<DevServerConfig, DevServerConfig>>;
598
603
  metro: z.ZodOptional<z.ZodCustom<AdditionalMetroConfig & MetroDevServerConfig, AdditionalMetroConfig & MetroDevServerConfig>>;
599
604
  plugins: z.ZodCustom<PluginInput, PluginInput>;
605
+ reactNativePath: z.ZodOptional<z.ZodString>;
600
606
  }, z.core.$strip>;
601
607
  type GraniteConfig = z.input<typeof pluginConfigSchema>;
602
608
  type ParsedGraniteConfig = z.output<typeof pluginConfigSchema>;
@@ -607,6 +613,7 @@ type CompleteGraniteConfig = {
607
613
  outdir: ParsedGraniteConfig['outdir'];
608
614
  pluginHooks: GranitePluginHooks;
609
615
  pluginConfigs: PluginConfig[];
616
+ reactNativePath?: string;
610
617
  };
611
618
  interface GranitePluginHooks {
612
619
  devServer: {
@@ -665,6 +672,7 @@ declare function resolveConfig(config: CompleteGraniteConfig): Promise<ResolvedP
665
672
  * @param config.metro - Configure Metro bundler settings
666
673
  * @param config.devServer - Configure Mpack dev server settings
667
674
  * @param config.plugins - Granite plugins to enhance functionality
675
+ * @param config.reactNativePath - Path to `react-native` directory (defaults to project's `react-native` package path)
668
676
  * @returns The processed configuration
669
677
  *
670
678
  * @example
package/dist/index.d.ts CHANGED
@@ -73,6 +73,10 @@ interface BuildConfig {
73
73
  * ```
74
74
  */
75
75
  extra?: any;
76
+ /**
77
+ * Path to `react-native` package path
78
+ */
79
+ reactNativePath?: string;
76
80
  }
77
81
  interface ResolverConfig {
78
82
  /**
@@ -487,6 +491,7 @@ interface AdditionalMetroConfig extends MetroConfig {
487
491
  babelConfig?: babel.TransformOptions;
488
492
  transformSync?: (id: string, code: string) => string;
489
493
  projectRoot?: MetroConfig['projectRoot'];
494
+ reactNativePath?: string;
490
495
  }
491
496
  //#endregion
492
497
  //#region src/types/GranitePlugin.d.ts
@@ -597,6 +602,7 @@ declare const pluginConfigSchema: z.ZodObject<{
597
602
  devServer: z.ZodOptional<z.ZodCustom<DevServerConfig, DevServerConfig>>;
598
603
  metro: z.ZodOptional<z.ZodCustom<AdditionalMetroConfig & MetroDevServerConfig, AdditionalMetroConfig & MetroDevServerConfig>>;
599
604
  plugins: z.ZodCustom<PluginInput, PluginInput>;
605
+ reactNativePath: z.ZodOptional<z.ZodString>;
600
606
  }, z.core.$strip>;
601
607
  type GraniteConfig = z.input<typeof pluginConfigSchema>;
602
608
  type ParsedGraniteConfig = z.output<typeof pluginConfigSchema>;
@@ -607,6 +613,7 @@ type CompleteGraniteConfig = {
607
613
  outdir: ParsedGraniteConfig['outdir'];
608
614
  pluginHooks: GranitePluginHooks;
609
615
  pluginConfigs: PluginConfig[];
616
+ reactNativePath?: string;
610
617
  };
611
618
  interface GranitePluginHooks {
612
619
  devServer: {
@@ -665,6 +672,7 @@ declare function resolveConfig(config: CompleteGraniteConfig): Promise<ResolvedP
665
672
  * @param config.metro - Configure Metro bundler settings
666
673
  * @param config.devServer - Configure Mpack dev server settings
667
674
  * @param config.plugins - Granite plugins to enhance functionality
675
+ * @param config.reactNativePath - Path to `react-native` directory (defaults to project's `react-native` package path)
668
676
  * @returns The processed configuration
669
677
  *
670
678
  * @example
package/dist/index.js CHANGED
@@ -230,7 +230,8 @@ async function mergeConfig(base, ...configs) {
230
230
  swc: mergeSwc(resolvedAcc?.swc, resolvedCurr?.swc),
231
231
  devServer: mergeDevServer(resolvedAcc?.devServer, resolvedCurr?.devServer),
232
232
  metro: mergeMetro(resolvedAcc?.metro, resolvedCurr?.metro),
233
- extra: mergeExtra(resolvedAcc?.extra, resolvedCurr?.extra)
233
+ extra: mergeExtra(resolvedAcc?.extra, resolvedCurr?.extra),
234
+ reactNativePath: resolvedCurr.reactNativePath ?? resolvedAcc.reactNativePath
234
235
  };
235
236
  }, resolveDynamicConfig(base));
236
237
  }
@@ -325,6 +326,7 @@ async function resolveConfig(config) {
325
326
  function resolveMetroConfig(pluginConfig) {
326
327
  return {
327
328
  ...pluginConfig.metro ?? {},
329
+ reactNativePath: pluginConfig.reactNativePath,
328
330
  babelConfig: pluginConfig.babel,
329
331
  transformSync: pluginConfig?.transformer?.transformSync
330
332
  };
@@ -362,7 +364,8 @@ const pluginConfigSchema = z.object({
362
364
  build: z.custom().optional(),
363
365
  devServer: z.custom().optional(),
364
366
  metro: z.custom().optional(),
365
- plugins: z.custom()
367
+ plugins: z.custom(),
368
+ reactNativePath: z.string().optional()
366
369
  });
367
370
 
368
371
  //#endregion
@@ -392,6 +395,7 @@ const pluginConfigSchema = z.object({
392
395
  * @param config.metro - Configure Metro bundler settings
393
396
  * @param config.devServer - Configure Mpack dev server settings
394
397
  * @param config.plugins - Granite plugins to enhance functionality
398
+ * @param config.reactNativePath - Path to `react-native` directory (defaults to project's `react-native` package path)
395
399
  * @returns The processed configuration
396
400
  *
397
401
  * @example
@@ -450,7 +454,8 @@ const defineConfig = async (config) => {
450
454
  host
451
455
  }),
452
456
  ...configs
453
- ].filter(isNotNil)
457
+ ].filter(isNotNil),
458
+ reactNativePath: parsed.reactNativePath
454
459
  };
455
460
  };
456
461
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@granite-js/plugin-core",
3
3
  "type": "module",
4
- "version": "0.1.34",
4
+ "version": "1.0.1",
5
5
  "description": "The core plugin module for Granite",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
@@ -34,15 +34,15 @@
34
34
  "dist"
35
35
  ],
36
36
  "devDependencies": {
37
- "@types/node": "^24.3.0",
37
+ "@types/node": "24.10.12",
38
38
  "@vitest/coverage-v8": "^4.0.12",
39
- "tsdown": "^0.16.5",
40
- "typescript": "^5.6.3",
39
+ "tsdown": "0.20.3",
40
+ "typescript": "5.9.3",
41
41
  "vitest": "^4.0.12"
42
42
  },
43
43
  "dependencies": {
44
- "@granite-js/utils": "0.1.34",
45
- "@swc/core": "^1.15.8",
44
+ "@granite-js/utils": "1.0.1",
45
+ "@swc/core": "1.15.8",
46
46
  "@types/babel__core": "^7",
47
47
  "@types/connect": "^3",
48
48
  "@types/ws": "^8.18.0",