@nx/react-native 20.3.1 → 20.4.0-beta.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2024 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2025 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "20.3.1",
3
+ "version": "20.4.0-beta.0",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: \n\n-Integration with libraries such as Jest, Detox, and Storybook.\n-Scaffolding for creating buildable libraries that can be published to npm.\n-Utilities for automatic workspace refactoring.",
6
6
  "keywords": [
@@ -36,12 +36,12 @@
36
36
  "node-fetch": "^2.6.7",
37
37
  "tsconfig-paths": "^4.1.2",
38
38
  "tslib": "^2.3.0",
39
- "@nx/devkit": "20.3.1",
40
- "@nx/jest": "20.3.1",
41
- "@nx/js": "20.3.1",
42
- "@nx/eslint": "20.3.1",
43
- "@nx/react": "20.3.1",
44
- "@nx/workspace": "20.3.1"
39
+ "@nx/devkit": "20.4.0-beta.0",
40
+ "@nx/jest": "20.4.0-beta.0",
41
+ "@nx/js": "20.4.0-beta.0",
42
+ "@nx/eslint": "20.4.0-beta.0",
43
+ "@nx/react": "20.4.0-beta.0",
44
+ "@nx/workspace": "20.4.0-beta.0"
45
45
  },
46
46
  "executors": "./executors.json",
47
47
  "ng-update": {
@@ -88,17 +88,12 @@ async function addProject(host, options) {
88
88
  tags: options.parsedTags,
89
89
  targets: {},
90
90
  };
91
+ const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
91
92
  if (options.isUsingTsSolutionConfig) {
92
- const sourceEntry = !options.buildable
93
- ? options.js
94
- ? './src/index.js'
95
- : './src/index.ts'
96
- : undefined;
97
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
93
+ (0, devkit_1.writeJson)(host, packageJsonPath, {
98
94
  name: (0, get_import_path_1.getImportPath)(host, options.name),
99
95
  version: '0.0.1',
100
- main: sourceEntry,
101
- types: sourceEntry,
96
+ ...determineEntryFields(options),
102
97
  nx: {
103
98
  name: options.name,
104
99
  sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
@@ -119,12 +114,22 @@ async function addProject(host, options) {
119
114
  project: options.name,
120
115
  skipFormat: true,
121
116
  });
117
+ (0, devkit_1.updateJson)(host, packageJsonPath, (json) => {
118
+ if (json.type === 'module') {
119
+ // The @nx/rollup:configuration generator can set the type to 'module' which would
120
+ // potentially break this library.
121
+ delete json.type;
122
+ }
123
+ return json;
124
+ });
122
125
  const external = ['react/jsx-runtime', 'react-native', 'react', 'react-dom'];
123
126
  project.targets.build = {
124
127
  executor: '@nx/rollup:rollup',
125
128
  outputs: ['{options.outputPath}'],
126
129
  options: {
127
- outputPath: `dist/${options.projectRoot}`,
130
+ outputPath: options.isUsingTsSolutionConfig
131
+ ? `${options.projectRoot}/dist`
132
+ : `dist/${options.projectRoot}`,
128
133
  tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
129
134
  project: `${options.projectRoot}/package.json`,
130
135
  entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
@@ -189,4 +194,23 @@ function maybeJs(options, path) {
189
194
  ? path.replace(/\.tsx?$/, '.js')
190
195
  : path;
191
196
  }
197
+ function determineEntryFields(options) {
198
+ if (options.buildable) {
199
+ return {};
200
+ }
201
+ return {
202
+ main: options.js ? './src/index.js' : './src/index.ts',
203
+ types: options.js ? './src/index.js' : './src/index.ts',
204
+ exports: {
205
+ '.': options.js
206
+ ? './src/index.js'
207
+ : {
208
+ types: './src/index.ts',
209
+ import: './src/index.ts',
210
+ default: './src/index.ts',
211
+ },
212
+ './package.json': './package.json',
213
+ },
214
+ };
215
+ }
192
216
  exports.default = reactNativeLibraryGenerator;