@granite-js/mpack 0.1.30 → 0.1.31

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,5 +1,17 @@
1
1
  # @granite-js/mpack
2
2
 
3
+ ## 0.1.31
4
+
5
+ ### Patch Changes
6
+
7
+ - 9bf8b50: expose resolveRequest option
8
+ - e957833: expose `resolver.resolverMainFields` and `resolver.unstable_conditionNames` options
9
+ - Updated dependencies [9bf8b50]
10
+ - Updated dependencies [e957833]
11
+ - @granite-js/plugin-core@0.1.31
12
+ - @granite-js/devtools-frontend@0.1.31
13
+ - @granite-js/utils@0.1.31
14
+
3
15
  ## 0.1.30
4
16
 
5
17
  ### Patch Changes
@@ -1,7 +1,6 @@
1
- interface CustomResolutionContext {
2
- sourceExts: string[];
3
- originModulePath: string;
4
- preferNativePlatform?: boolean;
1
+ import type { MetroResolutionContext } from '@granite-js/plugin-core';
2
+ interface CreateResolverOptions {
3
+ conditionNames?: string[];
5
4
  }
6
- export declare function createResolver(rootPath: string): (context: CustomResolutionContext, request: string, platform: string | null) => any;
5
+ export declare function createResolver(rootPath: string, options?: CreateResolverOptions): (context: MetroResolutionContext, request: string, platform: string | null) => any;
7
6
  export {};
@@ -51,7 +51,7 @@ const SUPPORTED_BUILTIN_FALLBACKS = {
51
51
  };
52
52
  const builtinModules = new Set(import_module.default.builtinModules);
53
53
  const resolvers = /* @__PURE__ */ new Map();
54
- function createResolver(rootPath) {
54
+ function createResolver(rootPath, options) {
55
55
  function createResolverImpl(context, platform, rootPath2) {
56
56
  const baseExtensions = context.sourceExts.map((extension) => `.${extension}`);
57
57
  let finalExtensions = [...baseExtensions];
@@ -63,9 +63,9 @@ function createResolver(rootPath) {
63
63
  }
64
64
  const resolver = import_enhanced_resolve.default.create.sync({
65
65
  extensions: finalExtensions,
66
- mainFields: import_constants.RESOLVER_MAIN_FIELDS,
66
+ mainFields: context.mainFields,
67
+ conditionNames: options?.conditionNames ?? [...import_constants.RESOLVER_EXPORTS_MAP_CONDITIONS, "require", "node", "default"],
67
68
  mainFiles: ["index"],
68
- conditionNames: [...import_constants.RESOLVER_EXPORTS_MAP_CONDITIONS, "require", "node", "default"],
69
69
  modules: ["node_modules", import_path.default.join(rootPath2, "src")]
70
70
  });
71
71
  function resolve(context2, request) {
@@ -63,6 +63,9 @@ async function getMetroConfig({ rootPath }, additionalConfig) {
63
63
  const reactNativePath = import_path.default.dirname(resolveFromRoot("react-native/package.json", rootPath));
64
64
  const resolvedRootPath = await (0, import_getMonorepoRoot.getMonorepoRoot)(rootPath);
65
65
  const packageRootPath = await (0, import_utils.getPackageRoot)();
66
+ const resolveRequest = additionalConfig?.resolver?.resolveRequest ?? (0, import_enhancedResolver.createResolver)(rootPath, {
67
+ conditionNames: additionalConfig?.resolver?.conditionNames
68
+ });
66
69
  return (0, import_loadConfig.mergeConfig)(defaultConfig, {
67
70
  projectRoot: additionalConfig?.projectRoot || rootPath,
68
71
  watchFolders: [resolvedRootPath, packageRootPath, ...additionalConfig?.watchFolders || []],
@@ -94,7 +97,7 @@ async function getMetroConfig({ rootPath }, additionalConfig) {
94
97
  // metro
95
98
  platforms: ["android", "ios"],
96
99
  useWatchman: false,
97
- resolveRequest: (0, import_enhancedResolver.createResolver)(rootPath),
100
+ resolveRequest,
98
101
  // metro-file-map
99
102
  sourceExts: [...import_constants.SOURCE_EXTENSIONS.map((extension) => extension.replace(/^\.?/, "")), "cjs", "mjs"],
100
103
  blockList: (0, import_exclusionList.default)(
@@ -102,7 +105,8 @@ async function getMetroConfig({ rootPath }, additionalConfig) {
102
105
  ),
103
106
  nodeModulesPaths: additionalConfig?.resolver?.nodeModulesPaths || [],
104
107
  extraNodeModules: additionalConfig?.resolver?.extraNodeModules || {},
105
- disableHierarchicalLookup: additionalConfig?.resolver?.disableHierarchicalLookup
108
+ disableHierarchicalLookup: additionalConfig?.resolver?.disableHierarchicalLookup,
109
+ resolverMainFields: additionalConfig?.resolver?.resolverMainFields ?? import_constants.RESOLVER_MAIN_FIELDS
106
110
  },
107
111
  serializer: {
108
112
  getModulesRunBeforeMainModule: () => [resolveFromRoot("react-native/Libraries/Core/InitializeCore", rootPath)],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granite-js/mpack",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "A bundler for Granite apps",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -89,9 +89,9 @@
89
89
  "@babel/traverse": "^7.14.0",
90
90
  "@babel/types": "^7.0.0",
91
91
  "@fastify/static": "7.0.1",
92
- "@granite-js/devtools-frontend": "0.1.30",
93
- "@granite-js/plugin-core": "0.1.30",
94
- "@granite-js/utils": "0.1.30",
92
+ "@granite-js/devtools-frontend": "0.1.31",
93
+ "@granite-js/plugin-core": "0.1.31",
94
+ "@granite-js/utils": "0.1.31",
95
95
  "@inquirer/prompts": "^7.2.3",
96
96
  "@react-native-community/cli-plugin-metro": "11.3.7",
97
97
  "@react-native-community/cli-server-api": "11.3.7",