@nx/expo 17.0.3 → 17.0.4

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.
Files changed (109) hide show
  1. package/.eslintrc.json +3 -0
  2. package/LICENSE +1 -1
  3. package/README.md +9 -4
  4. package/docs/export-examples.md +112 -0
  5. package/docs/start-examples.md +6 -0
  6. package/executors.json +5 -0
  7. package/generators.json +2 -2
  8. package/migrations.json +114 -6
  9. package/package.json +12 -16
  10. package/plugin.d.ts +1 -0
  11. package/plugin.js +6 -0
  12. package/plugins/metro-resolver.js +4 -1
  13. package/plugins/plugin.d.ts +14 -0
  14. package/plugins/plugin.js +150 -0
  15. package/plugins/with-nx-metro.js +6 -2
  16. package/plugins/with-nx-webpack.d.ts +1 -1
  17. package/plugins/with-nx-webpack.js +8 -4
  18. package/src/executors/build/build.impl.js +2 -1
  19. package/src/executors/build/schema.json +1 -1
  20. package/src/executors/build-list/build-list.impl.js +2 -3
  21. package/src/executors/build-list/schema.json +1 -1
  22. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +4 -0
  23. package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -0
  24. package/src/executors/ensure-symlink/schema.json +1 -1
  25. package/src/executors/export/export.impl.d.ts +1 -0
  26. package/src/executors/export/export.impl.js +25 -15
  27. package/src/executors/export/schema.d.ts +4 -2
  28. package/src/executors/export/schema.json +14 -13
  29. package/src/executors/install/install.impl.js +0 -2
  30. package/src/executors/install/schema.json +1 -1
  31. package/src/executors/prebuild/prebuild.impl.js +11 -5
  32. package/src/executors/prebuild/schema.json +2 -1
  33. package/src/executors/run/schema.json +1 -1
  34. package/src/executors/serve/lib/is-packager-running.d.ts +1 -0
  35. package/src/executors/serve/lib/is-packager-running.js +15 -0
  36. package/src/executors/serve/schema.d.ts +7 -0
  37. package/src/executors/serve/schema.json +35 -0
  38. package/src/executors/serve/serve.impl.d.ts +11 -0
  39. package/src/executors/serve/serve.impl.js +105 -0
  40. package/src/executors/start/schema.json +1 -1
  41. package/src/executors/start/start.impl.js +7 -1
  42. package/src/executors/submit/schema.json +1 -1
  43. package/src/executors/submit/submit.impl.js +2 -1
  44. package/src/executors/sync-deps/schema.d.ts +1 -0
  45. package/src/executors/sync-deps/schema.json +6 -1
  46. package/src/executors/sync-deps/sync-deps.impl.d.ts +4 -3
  47. package/src/executors/sync-deps/sync-deps.impl.js +33 -11
  48. package/src/executors/update/schema.json +1 -1
  49. package/src/executors/update/update.impl.js +7 -4
  50. package/src/generators/application/application.js +27 -7
  51. package/src/generators/application/files/app.json.template +2 -0
  52. package/src/generators/application/files/eas.json.template +0 -3
  53. package/src/generators/application/files/metro.config.js.template +1 -5
  54. package/src/generators/application/files/src/app/App.tsx.template +50 -13
  55. package/src/generators/application/files/webpack.config.js.template +57 -0
  56. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  57. package/src/generators/application/lib/add-e2e.js +86 -0
  58. package/src/generators/application/lib/add-project.js +20 -22
  59. package/src/generators/application/lib/create-application-files.js +0 -2
  60. package/src/generators/application/lib/normalize-options.d.ts +6 -0
  61. package/src/generators/application/lib/normalize-options.js +33 -1
  62. package/src/generators/application/schema.d.ts +2 -1
  63. package/src/generators/application/schema.json +4 -4
  64. package/src/generators/component/files/__fileName__.tsx.template +1 -1
  65. package/src/generators/component/schema.d.ts +3 -3
  66. package/src/generators/component/schema.json +4 -4
  67. package/src/generators/init/init.d.ts +3 -2
  68. package/src/generators/init/init.js +44 -40
  69. package/src/generators/init/schema.d.ts +3 -3
  70. package/src/generators/init/schema.json +11 -16
  71. package/src/generators/library/files/lib/.babelrc.js.template +21 -0
  72. package/src/generators/library/lib/normalize-options.js +5 -0
  73. package/src/generators/library/library.js +52 -38
  74. package/src/generators/library/schema.d.ts +1 -0
  75. package/src/generators/library/schema.json +2 -2
  76. package/src/migrations/update-16-6-0/update-metro-config.js +1 -5
  77. package/src/migrations/update-16-9-0/remove-types-react-native.js +2 -9
  78. package/src/migrations/update-16-9-0/update-eas-cli-version.js +1 -2
  79. package/src/migrations/{update-16-1-4/add-detox-app-json.d.ts → update-18-0-0/change-outputDir-export-target.d.ts} +1 -1
  80. package/src/migrations/update-18-0-0/change-outputDir-export-target.js +25 -0
  81. package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
  82. package/src/migrations/update-18-0-0/remove-block-list.js +28 -0
  83. package/src/migrations/update-18-0-0/remove-eas-cli.d.ts +12 -0
  84. package/src/migrations/update-18-0-0/remove-eas-cli.js +18 -0
  85. package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
  86. package/src/migrations/update-18-0-0/remove-symlink-target.js +29 -0
  87. package/src/utils/add-jest.d.ts +1 -1
  88. package/src/utils/add-jest.js +15 -5
  89. package/src/utils/add-linting.d.ts +1 -0
  90. package/src/utils/add-linting.js +1 -1
  91. package/src/utils/ensure-dependencies.d.ts +2 -0
  92. package/src/utils/ensure-dependencies.js +24 -0
  93. package/src/utils/find-all-npm-dependencies.js +4 -2
  94. package/src/utils/has-expo-plugin.d.ts +2 -0
  95. package/src/utils/has-expo-plugin.js +11 -0
  96. package/src/utils/resolve-eas.d.ts +1 -0
  97. package/src/utils/resolve-eas.js +36 -0
  98. package/src/utils/versions.d.ts +14 -15
  99. package/src/utils/versions.js +15 -16
  100. package/collection.json +0 -0
  101. package/src/generators/application/lib/add-detox.d.ts +0 -3
  102. package/src/generators/application/lib/add-detox.js +0 -24
  103. package/src/generators/library/files/lib/babel.config.json +0 -17
  104. package/src/migrations/update-16-1-4/add-detox-app-json.js +0 -29
  105. package/src/utils/symlink-task.d.ts +0 -2
  106. package/src/utils/symlink-task.js +0 -18
  107. /package/src/generators/application/files/{babel.config.js.template → .babelrc.js.template} +0 -0
  108. /package/src/{generators/init/lib → utils}/init-root-babel-config.d.ts +0 -0
  109. /package/src/{generators/init/lib → utils}/init-root-babel-config.js +0 -0
package/.eslintrc.json CHANGED
@@ -27,6 +27,9 @@
27
27
  "nx",
28
28
  "@nx/rollup",
29
29
  "@nx/webpack",
30
+ "@nx/cypress",
31
+ "@nx/playwright",
32
+ "@nx/detox",
30
33
  "typescript",
31
34
  "eslint",
32
35
  "expo",
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -1,4 +1,9 @@
1
- <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
2
7
 
3
8
  <div style="text-align: center;">
4
9
 
@@ -15,9 +20,9 @@
15
20
 
16
21
  <hr>
17
22
 
18
- # Nx: Smart, Fast and Extensible Build System
23
+ # Nx: Smart Monorepos · Fast CI
19
24
 
20
- Nx is a next generation build system with first class monorepo support and powerful integrations.
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
21
26
 
22
27
  This package is a [Expo plugin for Nx](https://nx.dev/expo/overview).
23
28
 
@@ -59,5 +64,5 @@ npx nx@latest init
59
64
  - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
60
65
 
61
66
  <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
62
- width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
63
68
 
@@ -0,0 +1,112 @@
1
+ `project.json`:
2
+
3
+ ```json
4
+ {
5
+ "name": "mobile",
6
+ //...
7
+ "targets": {
8
+ //...
9
+ "export": {
10
+ "executor": "@nx/expo:export",
11
+ "options": {
12
+ "outputs": ["{options.outputDir}"],
13
+ "platform": "all",
14
+ "outputDir": "dist/apps/mobile"
15
+ },
16
+ "dependsOn": ["sync-deps"]
17
+ }
18
+ //...
19
+ }
20
+ }
21
+ ```
22
+
23
+ ```shell
24
+ nx run mobile:export
25
+ ```
26
+
27
+ ## Examples
28
+
29
+ {% tabs %}
30
+ {% tab label="Specify outputDir" %}
31
+ The `outputDir` option allows you to specify the output directory of your bundle:
32
+
33
+ ```json
34
+ "export": {
35
+ "executor": "@nx/expo:export",
36
+ "outputs": ["{options.outputDir}"],
37
+ "options": {
38
+ "platform": "all",
39
+ "bundler": "metro",
40
+ "outputDir": "dist/apps/mobile"
41
+ },
42
+ "dependsOn": ["sync-deps"]
43
+ },
44
+ ```
45
+
46
+ or run command: `nx run mobile:export --outputDir=dist/apps/mobile`.
47
+
48
+ {% /tab %}
49
+ {% tab label="Specify the platform" %}
50
+ The `platform` option allows you to specify the platform to compile with metro bundler: "ios", "android", "all", and "web".
51
+
52
+ For example, to bundle for web:
53
+
54
+ ```json
55
+ "export": {
56
+ "executor": "@nx/expo:export",
57
+ "outputs": ["{options.outputDir}"],
58
+ "options": {
59
+ "platform": "web",
60
+ "bundler": "metro",
61
+ "outputDir": "dist/apps/dogs"
62
+ },
63
+ "dependsOn": ["sync-deps"]
64
+ },
65
+ ```
66
+
67
+ or run command `nx export mobile --platform=web`.
68
+
69
+ {% /tab %}
70
+ {% tab label="Bundle for development" %}
71
+
72
+ The `dev` option allows you to bundle for development environments.
73
+
74
+ ```json
75
+ "export": {
76
+ "executor": "@nx/expo:export",
77
+ "outputs": ["{options.outputDir}"],
78
+ "options": {
79
+ "platform": "web",
80
+ "bundler": "metro",
81
+ "outputDir": "dist/apps/dogs",
82
+ "dev": true
83
+ },
84
+ "dependsOn": ["sync-deps"]
85
+ },
86
+ ```
87
+
88
+ or run command `nx export mobile --dev`.
89
+
90
+ {% /tab %}
91
+ {% tab label="Clear bundle cache" %}
92
+
93
+ The `clear` option allows you to clear bundle cache.
94
+
95
+ ```json
96
+ "export": {
97
+ "executor": "@nx/expo:export",
98
+ "outputs": ["{options.outputDir}"],
99
+ "options": {
100
+ "platform": "web",
101
+ "bundler": "metro",
102
+ "outputDir": "dist/apps/dogs",
103
+ "clear": true
104
+ },
105
+ "dependsOn": ["sync-deps"]
106
+ },
107
+ ```
108
+
109
+ or run command `nx export mobile --clear`.
110
+
111
+ {% /tab %}
112
+ {% /tabs %}
@@ -39,6 +39,8 @@ Opens your app in Expo Go in a currently running iOS simulator on your computer:
39
39
  }
40
40
  ```
41
41
 
42
+ or run command `nx start <your app name> --ios`.
43
+
42
44
  Opens your app in Expo Go on a connected Android device
43
45
 
44
46
  ```json
@@ -51,6 +53,8 @@ Opens your app in Expo Go on a connected Android device
51
53
  }
52
54
  ```
53
55
 
56
+ or run command `nx start <your app name> --android`.
57
+
54
58
  Opens your app in a web browser:
55
59
 
56
60
  ```json
@@ -63,6 +67,8 @@ Opens your app in a web browser:
63
67
  }
64
68
  ```
65
69
 
70
+ or run command `nx start <your app name> --web`.
71
+
66
72
  {% /tab %}
67
73
  {% tab label="Specify the host" %}
68
74
  The `host` option allows you to specify the type of host to use. `lan` uses the local network; `tunnel` ues any network by tunnel through ngrok; `localhost` connects to the dev server over localhost.
package/executors.json CHANGED
@@ -54,6 +54,11 @@
54
54
  "implementation": "./src/executors/submit/submit.impl",
55
55
  "schema": "./src/executors/submit/schema.json",
56
56
  "description": "Submit app binary to App Store and/or Play Store"
57
+ },
58
+ "serve": {
59
+ "implementation": "./src/executors/serve/serve.impl",
60
+ "schema": "./src/executors/serve/schema.json",
61
+ "description": "Serve up the Expo web app locally"
57
62
  }
58
63
  }
59
64
  }
package/generators.json CHANGED
@@ -4,9 +4,9 @@
4
4
  "extends": ["@nx/workspace"],
5
5
  "generators": {
6
6
  "init": {
7
- "factory": "./src/generators/init/init#expoInitGenerator",
7
+ "factory": "./src/generators/init/init#expoInitGeneratorInternal",
8
8
  "schema": "./src/generators/init/schema.json",
9
- "description": "Initialize the @nrwl/expo plugin",
9
+ "description": "Initialize the @nx/expo plugin",
10
10
  "hidden": true
11
11
  },
12
12
  "application": {
package/migrations.json CHANGED
@@ -36,12 +36,6 @@
36
36
  "description": "Update package.json eas build lifecycle scripts",
37
37
  "implementation": "./src/migrations/update-16-1-4/update-eas-scripts"
38
38
  },
39
- "add-detox-app-json-16-1-4": {
40
- "version": "16.1.4-beta.0",
41
- "cli": "nx",
42
- "description": "Add app.json for detox",
43
- "factory": "./src/migrations/update-16-1-4/add-detox-app-json"
44
- },
45
39
  "update-16-6-0-add-dependsOn": {
46
40
  "cli": "nx",
47
41
  "version": "16.6.0-beta.0",
@@ -65,6 +59,30 @@
65
59
  "version": "16.9.0-beta.1",
66
60
  "description": "Update eas.json cli version",
67
61
  "implementation": "./src/migrations/update-16-9-0/update-eas-cli-version"
62
+ },
63
+ "update-18-0-0-remove-block-list": {
64
+ "cli": "nx",
65
+ "version": "18.0.0-beta.0",
66
+ "description": "Remove blockList in metro.config.js",
67
+ "implementation": "./src/migrations/update-18-0-0/remove-block-list"
68
+ },
69
+ "update-18-0-0-remove-symlink-target": {
70
+ "cli": "nx",
71
+ "version": "18.0.0-beta.0",
72
+ "description": "Remove symlink target in project.json",
73
+ "implementation": "./src/migrations/update-18-0-0/remove-symlink-target"
74
+ },
75
+ "update-18-0-0-remove-eas-cli": {
76
+ "cli": "nx",
77
+ "version": "18.0.0-beta.0",
78
+ "description": "Remove eas-cli from package.json",
79
+ "implementation": "./src/migrations/update-18-0-0/remove-eas-cli"
80
+ },
81
+ "update-18-0-0-remove-offset-export-outputDir": {
82
+ "cli": "nx",
83
+ "version": "18.0.0-beta.0",
84
+ "description": "Remove the offset from the outputDir of the export target",
85
+ "implementation": "./src/migrations/update-18-0-0/change-outputDir-export-target"
68
86
  }
69
87
  },
70
88
  "packageJsonUpdates": {
@@ -576,6 +594,96 @@
576
594
  "alwaysAddToPackageJson": false
577
595
  }
578
596
  }
597
+ },
598
+ "17.1.0": {
599
+ "version": "17.1.0-beta.0",
600
+ "packages": {
601
+ "expo": {
602
+ "version": "49.0.16",
603
+ "alwaysAddToPackageJson": false
604
+ },
605
+ "@expo/cli": {
606
+ "version": "~0.10.13",
607
+ "alwaysAddToPackageJson": false
608
+ },
609
+ "react-native": {
610
+ "version": "0.72.6",
611
+ "alwaysAddToPackageJson": false
612
+ },
613
+ "react-native-web": {
614
+ "version": "~0.19.9",
615
+ "alwaysAddToPackageJson": false
616
+ },
617
+ "metro-resolver": {
618
+ "version": "0.76.8",
619
+ "alwaysAddToPackageJson": false
620
+ },
621
+ "metro": {
622
+ "version": "0.76.8",
623
+ "alwaysAddToPackageJson": false
624
+ }
625
+ }
626
+ },
627
+ "18.0.0": {
628
+ "version": "18.0.0-beta.0",
629
+ "packages": {
630
+ "expo": {
631
+ "version": "50.0.1",
632
+ "alwaysAddToPackageJson": false
633
+ },
634
+ "expo-splash-screen": {
635
+ "version": "~0.26.1",
636
+ "alwaysAddToPackageJson": false
637
+ },
638
+ "expo-status-bar": {
639
+ "version": "~1.11.1",
640
+ "alwaysAddToPackageJson": false
641
+ },
642
+ "@expo/cli": {
643
+ "version": "~0.16.5",
644
+ "alwaysAddToPackageJson": false
645
+ },
646
+ "babel-preset-expo": {
647
+ "version": "~10.0.0",
648
+ "alwaysAddToPackageJson": false
649
+ },
650
+ "@types/react": {
651
+ "version": "~18.2.45",
652
+ "alwaysAddToPackageJson": false
653
+ },
654
+ "react-native": {
655
+ "version": "~0.73.2",
656
+ "alwaysAddToPackageJson": false
657
+ },
658
+ "react-native-web": {
659
+ "version": "~0.19.9",
660
+ "alwaysAddToPackageJson": false
661
+ },
662
+ "@expo/metro-config": {
663
+ "version": "~0.17.3",
664
+ "alwaysAddToPackageJson": false
665
+ },
666
+ "@expo/metro-runtime": {
667
+ "version": "~3.1.1",
668
+ "addToPackageJson": "devDependencies"
669
+ },
670
+ "react-native-svg-transformer": {
671
+ "version": "1.2.0",
672
+ "alwaysAddToPackageJson": false
673
+ },
674
+ "react-native-svg": {
675
+ "version": "14.1.0",
676
+ "alwaysAddToPackageJson": false
677
+ },
678
+ "@testing-library/react-native": {
679
+ "version": "~12.4.2",
680
+ "alwaysAddToPackageJson": false
681
+ },
682
+ "jest-expo": {
683
+ "version": "~50.0.1",
684
+ "alwaysAddToPackageJson": false
685
+ }
686
+ }
579
687
  }
580
688
  }
581
689
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/expo",
3
- "version": "17.0.3",
3
+ "version": "17.0.4",
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": [
@@ -26,27 +26,23 @@
26
26
  "main": "./index.js",
27
27
  "types": "index.d.ts",
28
28
  "dependencies": {
29
+ "@nx/devkit": "17.0.4",
29
30
  "chalk": "^4.1.0",
30
31
  "enhanced-resolve": "^5.8.3",
31
32
  "fs-extra": "^11.1.0",
32
- "metro-config": "0.76.7",
33
- "metro-resolver": "0.76.7",
33
+ "metro-config": "~0.80.4",
34
+ "metro-resolver": "~0.80.4",
35
+ "node-fetch": "^2.6.7",
34
36
  "tslib": "^2.3.0",
35
37
  "tsconfig-paths": "^4.1.2",
36
38
  "tsconfig-paths-webpack-plugin": "^4.0.0",
37
- "@nx/detox": "17.0.3",
38
- "@nx/devkit": "17.0.3",
39
- "@nx/jest": "17.0.3",
40
- "@nx/js": "17.0.3",
41
- "@nx/eslint": "17.0.3",
42
- "@nx/react": "17.0.3",
43
- "@nx/webpack": "17.0.3",
44
- "@nrwl/expo": "17.0.3"
45
- },
46
- "peerDependencies": {
47
- "expo": ">= 49.0.0",
48
- "@expo/cli": ">= 0.10.0",
49
- "eas-cli": ">= 3.15.0"
39
+ "@nx/jest": "17.0.4",
40
+ "@nx/js": "17.0.4",
41
+ "@nx/eslint": "17.0.4",
42
+ "@nx/react": "17.0.4",
43
+ "@nx/web": "17.0.4",
44
+ "@nx/webpack": "17.0.4",
45
+ "@nrwl/expo": "17.0.4"
50
46
  },
51
47
  "executors": "./executors.json",
52
48
  "ng-update": {
package/plugin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { createNodes, createDependencies, ExpoPluginOptions, } from './plugins/plugin';
package/plugin.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDependencies = exports.createNodes = void 0;
4
+ var plugin_1 = require("./plugins/plugin");
5
+ Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
+ Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
@@ -27,6 +27,9 @@ function getResolveRequest(extensions) {
27
27
  if (resolvedPath) {
28
28
  return resolvedPath;
29
29
  }
30
+ if (debug) {
31
+ console.log(chalk.red(`[Nx] Unable to resolve with any resolver: ${realModuleName}`));
32
+ }
30
33
  throw new Error(`Cannot resolve ${chalk.bold(realModuleName)}`);
31
34
  };
32
35
  }
@@ -84,7 +87,7 @@ function tsconfigPathsResolver(context, extensions, realModuleName, platform, de
84
87
  }
85
88
  catch {
86
89
  if (debug) {
87
- console.log(chalk.red(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`));
90
+ console.log(chalk.cyan(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`));
88
91
  console.log(chalk.cyan(`[Nx] The following tsconfig paths was used:\n:${chalk.bold(JSON.stringify(paths, null, 2))}`));
89
92
  }
90
93
  }
@@ -0,0 +1,14 @@
1
+ import { CreateDependencies, CreateNodes } from '@nx/devkit';
2
+ export interface ExpoPluginOptions {
3
+ startTargetName?: string;
4
+ serveTargetName?: string;
5
+ runIosTargetName?: string;
6
+ runAndroidTargetName?: string;
7
+ exportTargetName?: string;
8
+ prebuildTargetName?: string;
9
+ installTargetName?: string;
10
+ buildTargetName?: string;
11
+ submitTargetName?: string;
12
+ }
13
+ export declare const createDependencies: CreateDependencies;
14
+ export declare const createNodes: CreateNodes<ExpoPluginOptions>;
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodes = exports.createDependencies = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const js_1 = require("@nx/js");
7
+ const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
+ const fs_1 = require("fs");
9
+ const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
10
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
11
+ const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'expo.hash');
12
+ const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
13
+ const calculatedTargets = {};
14
+ function readTargetsCache() {
15
+ return (0, devkit_1.readJsonFile)(cachePath);
16
+ }
17
+ function writeTargetsToCache(targets) {
18
+ (0, devkit_1.writeJsonFile)(cachePath, targets);
19
+ }
20
+ const createDependencies = () => {
21
+ writeTargetsToCache(calculatedTargets);
22
+ return [];
23
+ };
24
+ exports.createDependencies = createDependencies;
25
+ exports.createNodes = [
26
+ '**/app.{json,config.js}',
27
+ (configFilePath, options, context) => {
28
+ options = normalizeOptions(options);
29
+ const projectRoot = (0, path_1.dirname)(configFilePath);
30
+ // Do not create a project if package.json or project.json or metro.config.js isn't there.
31
+ const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
32
+ if (!siblingFiles.includes('package.json') ||
33
+ !siblingFiles.includes('metro.config.js')) {
34
+ return {};
35
+ }
36
+ const appConfig = getAppConfig(configFilePath, context);
37
+ // if appConfig.expo is not defined
38
+ if (!appConfig.expo) {
39
+ return {};
40
+ }
41
+ const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
42
+ (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
43
+ ]);
44
+ const targets = targetsCache[hash]
45
+ ? targetsCache[hash]
46
+ : buildExpoTargets(projectRoot, options, context);
47
+ calculatedTargets[hash] = targets;
48
+ return {
49
+ projects: {
50
+ [projectRoot]: {
51
+ targets,
52
+ },
53
+ },
54
+ };
55
+ },
56
+ ];
57
+ function buildExpoTargets(projectRoot, options, context) {
58
+ const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
59
+ const targets = {
60
+ [options.startTargetName]: {
61
+ command: `expo start`,
62
+ options: { cwd: projectRoot },
63
+ },
64
+ [options.serveTargetName]: {
65
+ command: `expo start --web`,
66
+ options: { cwd: projectRoot },
67
+ },
68
+ [options.runIosTargetName]: {
69
+ command: `expo run:ios`,
70
+ options: { cwd: projectRoot },
71
+ },
72
+ [options.runAndroidTargetName]: {
73
+ command: `expo run:android`,
74
+ options: { cwd: projectRoot },
75
+ },
76
+ [options.exportTargetName]: {
77
+ command: `expo export`,
78
+ options: { cwd: projectRoot },
79
+ cache: true,
80
+ dependsOn: [`^${options.exportTargetName}`],
81
+ inputs: getInputs(namedInputs),
82
+ outputs: [getOutputs(projectRoot, 'dist')],
83
+ },
84
+ [options.installTargetName]: {
85
+ command: `expo install`,
86
+ options: { cwd: devkit_1.workspaceRoot }, // install at workspace root
87
+ },
88
+ [options.prebuildTargetName]: {
89
+ executor: `@nx/expo:prebuild`,
90
+ },
91
+ [options.buildTargetName]: {
92
+ command: `eas build`,
93
+ options: { cwd: projectRoot },
94
+ },
95
+ [options.submitTargetName]: {
96
+ command: `eas submit`,
97
+ options: { cwd: projectRoot },
98
+ },
99
+ };
100
+ return targets;
101
+ }
102
+ function getAppConfig(configFilePath, context) {
103
+ const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
104
+ let module = load(resolvedPath);
105
+ return module.default ?? module;
106
+ }
107
+ function getInputs(namedInputs) {
108
+ return [
109
+ ...('production' in namedInputs
110
+ ? ['default', '^production']
111
+ : ['default', '^default']),
112
+ {
113
+ externalDependencies: ['expo'],
114
+ },
115
+ ];
116
+ }
117
+ function getOutputs(projectRoot, dir) {
118
+ if (projectRoot === '.') {
119
+ return `{projectRoot}/${dir}`;
120
+ }
121
+ else {
122
+ return `{workspaceRoot}/${projectRoot}/${dir}`;
123
+ }
124
+ }
125
+ /**
126
+ * Load the module after ensuring that the require cache is cleared.
127
+ */
128
+ function load(path) {
129
+ // Clear cache if the path is in the cache
130
+ if (require.cache[path]) {
131
+ for (const k of Object.keys(require.cache)) {
132
+ delete require.cache[k];
133
+ }
134
+ }
135
+ // Then require
136
+ return require(path);
137
+ }
138
+ function normalizeOptions(options) {
139
+ options ??= {};
140
+ options.startTargetName ??= 'start';
141
+ options.serveTargetName ??= 'serve';
142
+ options.runIosTargetName ??= 'run-ios';
143
+ options.runAndroidTargetName ??= 'run-android';
144
+ options.exportTargetName ??= 'export';
145
+ options.prebuildTargetName ??= 'prebuild';
146
+ options.installTargetName ??= 'install';
147
+ options.buildTargetName ??= 'build';
148
+ options.submitTargetName ??= 'submit';
149
+ return options;
150
+ }
@@ -11,14 +11,18 @@ async function withNxMetro(userConfig, opts = {}) {
11
11
  process.env.NX_REACT_NATIVE_DEBUG = 'true';
12
12
  if (opts.extensions)
13
13
  extensions.push(...opts.extensions);
14
- let watchFolders = [devkit_1.workspaceRoot];
14
+ let watchFolders = (0, fs_extra_1.readdirSync)(devkit_1.workspaceRoot)
15
+ .filter((fileName) => !['dist', 'e2e'].includes(fileName) && !fileName.startsWith('.'))
16
+ .map((fileName) => (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, fileName))
17
+ .filter((filePath) => (0, fs_extra_1.statSync)(filePath).isDirectory());
15
18
  if (opts.watchFolders?.length) {
16
19
  watchFolders = watchFolders.concat(opts.watchFolders);
17
20
  }
18
- watchFolders = watchFolders.filter((folder) => (0, fs_extra_1.existsSync)(folder));
21
+ watchFolders = [...new Set(watchFolders)].filter((folder) => (0, fs_extra_1.existsSync)(folder));
19
22
  const nxConfig = {
20
23
  resolver: {
21
24
  resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions),
25
+ nodeModulesPaths: [(0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'node_modules')],
22
26
  },
23
27
  watchFolders,
24
28
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @deprecated TODO(v17) use bundler: 'metro' instead, will be removed in 16.0.0
2
+ * @deprecated TODO(v19) use bundler: 'metro' instead, will be removed in v19
3
3
  * This function add additional rules to expo's webpack config to make expo web working
4
4
  */
5
5
  export declare function withNxWebpack(config: any): Promise<any>;
@@ -4,12 +4,12 @@ exports.withNxWebpack = void 0;
4
4
  const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
5
5
  const path_1 = require("path");
6
6
  /**
7
- * @deprecated TODO(v17) use bundler: 'metro' instead, will be removed in 16.0.0
7
+ * @deprecated TODO(v19) use bundler: 'metro' instead, will be removed in v19
8
8
  * This function add additional rules to expo's webpack config to make expo web working
9
9
  */
10
10
  async function withNxWebpack(config) {
11
11
  // add additional rule to load files under libs
12
- const rules = config.module.rules[1]?.oneOf;
12
+ const rules = config.module.rules.find((rule) => Array.isArray(rule.oneOf))?.oneOf;
13
13
  if (rules) {
14
14
  rules.push({
15
15
  test: /\.(mjs|[jt]sx?)$/,
@@ -36,12 +36,16 @@ async function withNxWebpack(config) {
36
36
  config.resolve.plugins = [];
37
37
  }
38
38
  const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
39
- const tsConfigPath = (0, path_1.resolve)('tsconfig.json');
39
+ const tsConfigPath = (0, path_1.resolve)(__dirname, 'tsconfig.json');
40
40
  config.resolve.plugins.push(new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({
41
41
  configFile: tsConfigPath,
42
42
  extensions,
43
43
  }));
44
- config.resolve.symlinks = true;
44
+ config.resolve.fallback = {
45
+ ...config.resolve.fallback,
46
+ crypto: require.resolve('crypto-browserify'),
47
+ stream: require.resolve('stream-browserify'),
48
+ };
45
49
  return config;
46
50
  }
47
51
  exports.withNxWebpack = withNxWebpack;