@nx/expo 19.5.0 → 19.5.2

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": "@nx/expo",
3
- "version": "19.5.0",
3
+ "version": "19.5.2",
4
4
  "private": false,
5
5
  "description": "The Expo Plugin for Nx contains executors and generators for managing and developing an expo application within your workspace. For example, you can directly build for different target platforms as well as generate projects and publish your code.",
6
6
  "keywords": [
@@ -28,7 +28,7 @@
28
28
  "main": "./index",
29
29
  "types": "index.d.ts",
30
30
  "dependencies": {
31
- "@nx/devkit": "19.5.0",
31
+ "@nx/devkit": "19.5.2",
32
32
  "chalk": "^4.1.0",
33
33
  "enhanced-resolve": "^5.8.3",
34
34
  "fs-extra": "^11.1.0",
@@ -37,13 +37,13 @@
37
37
  "node-fetch": "^2.6.7",
38
38
  "tslib": "^2.3.0",
39
39
  "tsconfig-paths": "^4.1.2",
40
- "@nx/jest": "19.5.0",
41
- "@nx/js": "19.5.0",
42
- "@nx/eslint": "19.5.0",
43
- "@nx/react": "19.5.0",
44
- "@nx/web": "19.5.0",
45
- "@nx/webpack": "19.5.0",
46
- "@nrwl/expo": "19.5.0"
40
+ "@nx/jest": "19.5.2",
41
+ "@nx/js": "19.5.2",
42
+ "@nx/eslint": "19.5.2",
43
+ "@nx/react": "19.5.2",
44
+ "@nx/web": "19.5.2",
45
+ "@nx/webpack": "19.5.2",
46
+ "@nrwl/expo": "19.5.2"
47
47
  },
48
48
  "executors": "./executors.json",
49
49
  "ng-update": {
@@ -1 +1 @@
1
- export declare function getResolveRequest(extensions: string[]): (_context: any, realModuleName: string, platform: string | null) => any;
1
+ export declare function getResolveRequest(extensions: string[], exportsConditionNames?: string[], mainFields?: string[]): (_context: any, realModuleName: string, platform: string | null) => any;
@@ -14,16 +14,14 @@ const devkit_1 = require("@nx/devkit");
14
14
  * This resolve function requires projectRoot to be set to
15
15
  * workspace root in order modules and assets to be registered and watched.
16
16
  */
17
- function getResolveRequest(extensions) {
17
+ function getResolveRequest(extensions, exportsConditionNames = [], mainFields = []) {
18
18
  return function (_context, realModuleName, platform) {
19
19
  const debug = process.env.NX_REACT_NATIVE_DEBUG === 'true';
20
- if (debug)
21
- console.log(chalk.cyan(`[Nx] Resolving: ${realModuleName}`));
22
20
  const { resolveRequest, ...context } = _context;
23
- const resolvedPath = resolveRequestFromContext(resolveRequest, _context, realModuleName, platform, debug) ||
24
- defaultMetroResolver(context, realModuleName, platform, debug) ||
25
- tsconfigPathsResolver(context, extensions, realModuleName, platform, debug) ||
26
- pnpmResolver(extensions, context, realModuleName, debug);
21
+ const resolvedPath = resolveRequestFromContext(resolveRequest, _context, realModuleName, platform, debug) ??
22
+ defaultMetroResolver(context, realModuleName, platform, debug) ??
23
+ tsconfigPathsResolver(context, extensions, realModuleName, platform, debug) ??
24
+ pnpmResolver(extensions, context, realModuleName, debug, exportsConditionNames, mainFields);
27
25
  if (resolvedPath) {
28
26
  return resolvedPath;
29
27
  }
@@ -60,7 +58,7 @@ function defaultMetroResolver(context, realModuleName, platform, debug) {
60
58
  * @returns path if resolved, else undefined
61
59
  * This pnpm resolver is inspired from https://github.com/vjpr/pnpm-react-native-example/blob/main/packages/pnpm-expo-helper/util/make-resolver.js
62
60
  */
63
- function pnpmResolver(extensions, context, realModuleName, debug) {
61
+ function pnpmResolver(extensions, context, realModuleName, debug, exportsConditionNames = [], mainFields = []) {
64
62
  try {
65
63
  const pnpmResolve = getPnpmResolver(extensions);
66
64
  const lookupStartPath = (0, path_1.dirname)(context.originModulePath);
@@ -118,7 +116,7 @@ function getMatcher(debug) {
118
116
  * It is inspired form https://github.com/vjpr/pnpm-expo-example/blob/main/packages/pnpm-expo-helper/util/make-resolver.js.
119
117
  */
120
118
  let resolver;
121
- function getPnpmResolver(extensions) {
119
+ function getPnpmResolver(extensions, exportsConditionNames = [], mainFields = []) {
122
120
  if (!resolver) {
123
121
  const fileSystem = new enhanced_resolve_1.CachedInputFileSystem(fs, 4000);
124
122
  resolver = enhanced_resolve_1.ResolverFactory.createResolver({
@@ -126,8 +124,16 @@ function getPnpmResolver(extensions) {
126
124
  extensions: extensions.map((extension) => '.' + extension),
127
125
  useSyncFileSystemCalls: true,
128
126
  modules: [(0, path_1.join)(devkit_1.workspaceRoot, 'node_modules'), 'node_modules'],
129
- conditionNames: ['native', 'browser', 'require', 'default'],
130
- mainFields: ['react-native', 'browser', 'main'],
127
+ conditionNames: [
128
+ 'native',
129
+ 'browser',
130
+ 'require',
131
+ 'default',
132
+ 'react-native',
133
+ 'node',
134
+ ...exportsConditionNames,
135
+ ],
136
+ mainFields: ['react-native', 'browser', 'main', ...mainFields],
131
137
  aliasFields: ['browser'],
132
138
  });
133
139
  }
@@ -1,8 +1,25 @@
1
1
  import type { MetroConfig } from 'metro-config';
2
2
  interface WithNxOptions {
3
+ /**
4
+ * Change this to true to see debugging info.
5
+ */
3
6
  debug?: boolean;
7
+ /**
8
+ * A list of additional file extensions to resolve
9
+ * All the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
10
+ */
4
11
  extensions?: string[];
12
+ /**
13
+ * A list of additional folders to watch for changes
14
+ * By default, it watches all the folders in the workspace root except 'dist' and 'e2e'
15
+ */
5
16
  watchFolders?: string[];
17
+ exportsConditionNames?: string[];
18
+ /**
19
+ * A list of main fields in package.json files to use for resolution
20
+ * If a library has a package.json with a main field that can't be resolved with the default conditions, you can add the name of the field to this list.
21
+ */
22
+ mainFields?: string[];
6
23
  }
7
24
  export declare function withNxMetro(userConfig: MetroConfig, opts?: WithNxOptions): Promise<import("metro-config").ConfigT>;
8
25
  export {};
@@ -22,7 +22,7 @@ async function withNxMetro(userConfig, opts = {}) {
22
22
  watchFolders = [...new Set(watchFolders)].filter((folder) => (0, fs_extra_1.existsSync)(folder));
23
23
  const nxConfig = {
24
24
  resolver: {
25
- resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions),
25
+ resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions, opts.exportsConditionNames, opts.mainFields),
26
26
  nodeModulesPaths: [(0, path_1.join)(devkit_1.workspaceRoot, 'node_modules')],
27
27
  },
28
28
  watchFolders,