react-native-builder-bob 0.41.0 → 0.42.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.
Files changed (190) hide show
  1. package/bin/bob +1 -1
  2. package/lib/package.json +93 -0
  3. package/lib/src/__tests__/babel.test.d.ts +1 -0
  4. package/lib/src/__tests__/babel.test.js +26 -0
  5. package/lib/src/__tests__/babel.test.js.map +1 -0
  6. package/lib/src/__tests__/init.test.d.ts +1 -0
  7. package/lib/src/__tests__/init.test.js +93 -0
  8. package/lib/src/__tests__/init.test.js.map +1 -0
  9. package/lib/src/__tests__/resolveModuleSpecifier.test.d.ts +1 -0
  10. package/lib/src/__tests__/resolveModuleSpecifier.test.js +95 -0
  11. package/lib/src/__tests__/resolveModuleSpecifier.test.js.map +1 -0
  12. package/lib/src/__tests__/typescript-declarations.test.d.ts +1 -0
  13. package/lib/src/__tests__/typescript-declarations.test.js +193 -0
  14. package/lib/src/__tests__/typescript-declarations.test.js.map +1 -0
  15. package/lib/src/__tests__/typescript.test.d.ts +1 -0
  16. package/lib/src/__tests__/typescript.test.js +243 -0
  17. package/lib/src/__tests__/typescript.test.js.map +1 -0
  18. package/lib/src/__tests__/updateSourceMap.test.d.ts +1 -0
  19. package/lib/src/__tests__/updateSourceMap.test.js +84 -0
  20. package/lib/src/__tests__/updateSourceMap.test.js.map +1 -0
  21. package/lib/src/babel.d.ts +19 -0
  22. package/lib/src/babel.js +58 -0
  23. package/lib/src/babel.js.map +1 -0
  24. package/lib/src/build.d.ts +14 -0
  25. package/lib/src/build.js +122 -0
  26. package/lib/src/build.js.map +1 -0
  27. package/lib/src/configs/babel-config.cjs +46 -0
  28. package/lib/src/configs/babel-config.cjs.map +1 -0
  29. package/lib/src/configs/babel-config.d.cts +15 -0
  30. package/lib/src/configs/babel-preset.cjs +66 -0
  31. package/lib/src/configs/babel-preset.cjs.map +1 -0
  32. package/lib/src/configs/babel-preset.d.cts +19 -0
  33. package/lib/src/configs/metro-config.d.mts +4 -0
  34. package/{configs/metro-config.js → lib/src/configs/metro-config.mjs} +3 -6
  35. package/lib/src/configs/metro-config.mjs.map +1 -0
  36. package/lib/src/configs/vite-config.d.mts +2 -0
  37. package/lib/src/configs/vite-config.mjs +59 -0
  38. package/lib/src/configs/vite-config.mjs.map +1 -0
  39. package/lib/src/index.d.ts +1 -0
  40. package/lib/src/index.js +18 -0
  41. package/lib/src/index.js.map +1 -0
  42. package/lib/src/init.d.ts +1 -0
  43. package/lib/src/init.js +370 -0
  44. package/lib/src/init.js.map +1 -0
  45. package/lib/src/schema.d.ts +70 -0
  46. package/lib/src/schema.js +45 -0
  47. package/lib/src/schema.js.map +1 -0
  48. package/lib/src/targets/codegen/index.d.ts +4 -0
  49. package/lib/src/targets/codegen/index.js +54 -0
  50. package/lib/src/targets/codegen/index.js.map +1 -0
  51. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.d.ts +11 -0
  52. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.js +63 -0
  53. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.js.map +1 -0
  54. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.d.ts +1 -0
  55. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.js +103 -0
  56. package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.js.map +1 -0
  57. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.d.ts +16 -0
  58. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.js +59 -0
  59. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.js.map +1 -0
  60. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.d.ts +1 -0
  61. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.js +75 -0
  62. package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.js.map +1 -0
  63. package/lib/src/targets/commonjs.d.ts +9 -0
  64. package/lib/src/targets/commonjs.js +19 -0
  65. package/lib/src/targets/commonjs.js.map +1 -0
  66. package/lib/src/targets/custom.d.ts +9 -0
  67. package/lib/src/targets/custom.js +30 -0
  68. package/lib/src/targets/custom.js.map +1 -0
  69. package/lib/src/targets/module.d.ts +9 -0
  70. package/lib/src/targets/module.js +19 -0
  71. package/lib/src/targets/module.js.map +1 -0
  72. package/lib/src/targets/typescript.d.ts +12 -0
  73. package/lib/src/targets/typescript.js +387 -0
  74. package/lib/src/targets/typescript.js.map +1 -0
  75. package/lib/src/types.d.ts +24 -0
  76. package/lib/src/types.js +2 -0
  77. package/lib/src/types.js.map +1 -0
  78. package/lib/src/utils/androidAssemble.d.ts +8 -0
  79. package/lib/src/utils/androidAssemble.js +17 -0
  80. package/lib/src/utils/androidAssemble.js.map +1 -0
  81. package/lib/src/utils/compile.d.ts +16 -0
  82. package/lib/src/utils/compile.js +211 -0
  83. package/lib/src/utils/compile.js.map +1 -0
  84. package/lib/src/utils/isCodegenSpec.d.ts +1 -0
  85. package/lib/src/utils/isCodegenSpec.js +14 -0
  86. package/lib/src/utils/isCodegenSpec.js.map +1 -0
  87. package/lib/src/utils/isGitDirty.d.ts +1 -0
  88. package/lib/src/utils/isGitDirty.js +14 -0
  89. package/lib/src/utils/isGitDirty.js.map +1 -0
  90. package/lib/src/utils/loadConfig.d.ts +4 -0
  91. package/lib/src/utils/loadConfig.js +59 -0
  92. package/lib/src/utils/loadConfig.js.map +1 -0
  93. package/lib/src/utils/logger.d.ts +10 -0
  94. package/lib/src/utils/logger.js +30 -0
  95. package/lib/src/utils/logger.js.map +1 -0
  96. package/lib/src/utils/prompts.d.ts +3 -0
  97. package/lib/src/utils/prompts.js +10 -0
  98. package/lib/src/utils/prompts.js.map +1 -0
  99. package/lib/src/utils/resolveModuleSpecifier.d.ts +21 -0
  100. package/lib/src/utils/resolveModuleSpecifier.js +57 -0
  101. package/lib/src/utils/resolveModuleSpecifier.js.map +1 -0
  102. package/lib/src/utils/spawn.d.ts +2 -0
  103. package/lib/src/utils/spawn.js +41 -0
  104. package/lib/src/utils/spawn.js.map +1 -0
  105. package/lib/src/utils/updateSourceMap.d.ts +11 -0
  106. package/lib/src/utils/updateSourceMap.js +56 -0
  107. package/lib/src/utils/updateSourceMap.js.map +1 -0
  108. package/lib/src/utils/workerize.d.ts +15 -0
  109. package/lib/src/utils/workerize.js +75 -0
  110. package/lib/src/utils/workerize.js.map +1 -0
  111. package/package.json +15 -13
  112. package/configs/babel-config.js +0 -54
  113. package/configs/babel-preset.js +0 -69
  114. package/configs/vite-config.mjs +0 -62
  115. package/lib/__fixtures__/project/MyNativeComponent.js +0 -8
  116. package/lib/__fixtures__/project/MyNativeComponent.js.map +0 -1
  117. package/lib/__fixtures__/project/NativeMyLib.js +0 -2
  118. package/lib/__fixtures__/project/NativeMyLib.js.map +0 -1
  119. package/lib/__fixtures__/project/code/$exports-input.js +0 -121
  120. package/lib/__fixtures__/project/code/$exports-input.js.map +0 -1
  121. package/lib/__fixtures__/project/code/$exports-output.js +0 -121
  122. package/lib/__fixtures__/project/code/$exports-output.js.map +0 -1
  123. package/lib/__fixtures__/project/code/$imports-input.js +0 -24
  124. package/lib/__fixtures__/project/code/$imports-input.js.map +0 -1
  125. package/lib/__fixtures__/project/code/$imports-output.js +0 -20
  126. package/lib/__fixtures__/project/code/$imports-output.js.map +0 -1
  127. package/lib/__fixtures__/project/code/MyNativeComponent.js +0 -8
  128. package/lib/__fixtures__/project/code/MyNativeComponent.js.map +0 -1
  129. package/lib/__fixtures__/project/code/NativeMyLib.js +0 -2
  130. package/lib/__fixtures__/project/code/NativeMyLib.js.map +0 -1
  131. package/lib/__fixtures__/project/code/a.js +0 -2
  132. package/lib/__fixtures__/project/code/a.js.map +0 -1
  133. package/lib/__fixtures__/project/code/b.js +0 -2
  134. package/lib/__fixtures__/project/code/b.js.map +0 -1
  135. package/lib/__fixtures__/project/code/e.story.js +0 -2
  136. package/lib/__fixtures__/project/code/e.story.js.map +0 -1
  137. package/lib/__fixtures__/project/f.js +0 -2
  138. package/lib/__fixtures__/project/f.js.map +0 -1
  139. package/lib/__fixtures__/project/index.js +0 -2
  140. package/lib/__fixtures__/project/index.js.map +0 -1
  141. package/lib/__tests__/babel.test.js +0 -28
  142. package/lib/__tests__/babel.test.js.map +0 -1
  143. package/lib/__tests__/init.test.js +0 -93
  144. package/lib/__tests__/init.test.js.map +0 -1
  145. package/lib/babel.js +0 -92
  146. package/lib/babel.js.map +0 -1
  147. package/lib/build.js +0 -141
  148. package/lib/build.js.map +0 -1
  149. package/lib/index.js +0 -16
  150. package/lib/index.js.map +0 -1
  151. package/lib/init.js +0 -371
  152. package/lib/init.js.map +0 -1
  153. package/lib/schema.js +0 -49
  154. package/lib/schema.js.map +0 -1
  155. package/lib/targets/codegen/index.js +0 -60
  156. package/lib/targets/codegen/index.js.map +0 -1
  157. package/lib/targets/codegen/patches/patchCodegenAndroidPackage.js +0 -74
  158. package/lib/targets/codegen/patches/patchCodegenAndroidPackage.js.map +0 -1
  159. package/lib/targets/codegen/patches/patchCodegenAndroidPackage.test.js +0 -106
  160. package/lib/targets/codegen/patches/patchCodegenAndroidPackage.test.js.map +0 -1
  161. package/lib/targets/codegen/patches/removeCodegenAppLevelCode.js +0 -57
  162. package/lib/targets/codegen/patches/removeCodegenAppLevelCode.js.map +0 -1
  163. package/lib/targets/codegen/patches/removeCodegenAppLevelCode.test.js +0 -78
  164. package/lib/targets/codegen/patches/removeCodegenAppLevelCode.test.js.map +0 -1
  165. package/lib/targets/commonjs.js +0 -34
  166. package/lib/targets/commonjs.js.map +0 -1
  167. package/lib/targets/custom.js +0 -40
  168. package/lib/targets/custom.js.map +0 -1
  169. package/lib/targets/module.js +0 -34
  170. package/lib/targets/module.js.map +0 -1
  171. package/lib/targets/typescript.js +0 -219
  172. package/lib/targets/typescript.js.map +0 -1
  173. package/lib/types.js +0 -6
  174. package/lib/types.js.map +0 -1
  175. package/lib/utils/androidAssemble.js +0 -29
  176. package/lib/utils/androidAssemble.js.map +0 -1
  177. package/lib/utils/compile.js +0 -217
  178. package/lib/utils/compile.js.map +0 -1
  179. package/lib/utils/isCodegenSpec.js +0 -22
  180. package/lib/utils/isCodegenSpec.js.map +0 -1
  181. package/lib/utils/loadConfig.js +0 -56
  182. package/lib/utils/loadConfig.js.map +0 -1
  183. package/lib/utils/logger.js +0 -35
  184. package/lib/utils/logger.js.map +0 -1
  185. package/lib/utils/prompts.js +0 -17
  186. package/lib/utils/prompts.js.map +0 -1
  187. package/lib/utils/spawn.js +0 -48
  188. package/lib/utils/spawn.js.map +0 -1
  189. package/lib/utils/workerize.js +0 -102
  190. package/lib/utils/workerize.js.map +0 -1
@@ -1,219 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = build;
7
- var _del = require("del");
8
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
- var _json = _interopRequireDefault(require("json5"));
10
- var _kleur = _interopRequireDefault(require("kleur"));
11
- var _os = require("os");
12
- var _path = _interopRequireDefault(require("path"));
13
- var _which = _interopRequireDefault(require("which"));
14
- var _spawn = require("../utils/spawn");
15
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
- async function build({
17
- source,
18
- root,
19
- output,
20
- report,
21
- options,
22
- variants,
23
- esm
24
- }) {
25
- report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
26
- await (0, _del.deleteAsync)([output]);
27
- report.info(`Generating type definitions with ${_kleur.default.blue('tsc')}`);
28
- const project = options?.project ? options.project : 'tsconfig.json';
29
- const tsconfig = _path.default.join(root, project);
30
- try {
31
- if (await _fsExtra.default.pathExists(tsconfig)) {
32
- try {
33
- const config = _json.default.parse(await _fsExtra.default.readFile(tsconfig, 'utf-8'));
34
- if (config.compilerOptions) {
35
- const conflicts = [];
36
- if (config.compilerOptions.declarationDir) {
37
- conflicts.push('compilerOptions.declarationDir');
38
- }
39
- if (config.compilerOptions.outDir && _path.default.join(root, config.compilerOptions.outDir) !== output) {
40
- conflicts.push('compilerOptions.outDir');
41
- }
42
- if (conflicts.length) {
43
- report.warn(`Found following options in the config file which can conflict with the CLI options. Please remove them from ${_kleur.default.blue(project)}:${conflicts.reduce((acc, curr) => acc + `\n${_kleur.default.gray('-')} ${_kleur.default.yellow(curr)}`, '')}`);
44
- }
45
- }
46
- } catch (e) {
47
- report.warn(`Couldn't parse ${_kleur.default.blue(project)}. There might be validation errors.`);
48
- }
49
- } else {
50
- throw new Error(`Couldn't find a ${_kleur.default.blue(project)} in the project root.`);
51
- }
52
- let tsc;
53
- if (options?.tsc) {
54
- tsc = _path.default.resolve(root, options.tsc);
55
- if (!(await _fsExtra.default.pathExists(tsc))) {
56
- throw new Error(`The ${_kleur.default.blue('tsc')} binary doesn't seem to be installed at ${_kleur.default.blue(tsc)}. Please specify the correct path in options or remove it to use the workspace's version.`);
57
- }
58
- } else {
59
- const execpath = process.env.npm_execpath;
60
- const cli = execpath?.split(_path.default.sep).pop()?.includes('yarn') ? 'yarn' : 'npm';
61
- if (cli === 'yarn') {
62
- const result = await (0, _spawn.spawn)('yarn', ['bin', 'tsc'], {
63
- cwd: root,
64
- env: {
65
- ...process.env,
66
- FORCE_COLOR: '0'
67
- }
68
- });
69
- tsc = result.trim();
70
- } else {
71
- tsc = _path.default.resolve(root, 'node_modules', '.bin', 'tsc');
72
- }
73
- if ((0, _os.platform)() === 'win32' && !tsc.endsWith('.cmd')) {
74
- tsc += '.cmd';
75
- }
76
- }
77
- if (!(await _fsExtra.default.pathExists(tsc))) {
78
- try {
79
- tsc = await (0, _which.default)('tsc');
80
- if (await _fsExtra.default.pathExists(tsc)) {
81
- report.warn(`Failed to locate ${_kleur.default.blue('tsc')} in the workspace. Falling back to the binary found in ${_kleur.default.blue('PATH')} at ${_kleur.default.blue(tsc)}. Consider adding ${_kleur.default.blue('typescript')} to your ${_kleur.default.blue('devDependencies')} or specifying the ${_kleur.default.blue('tsc')} option for the typescript target.`);
82
- }
83
- } catch (e) {
84
- // Ignore
85
- }
86
- }
87
- if (tsc == null || !(await _fsExtra.default.pathExists(tsc))) {
88
- throw new Error(`The ${_kleur.default.blue('tsc')} binary doesn't seem to be installed under ${_kleur.default.blue('node_modules')} or present in $PATH. Make sure you have added ${_kleur.default.blue('typescript')} to your ${_kleur.default.blue('devDependencies')} or specify the ${_kleur.default.blue('tsc')} option for typescript.`);
89
- }
90
- const outputs = {};
91
- if (esm && variants.commonjs && variants.module) {
92
- outputs.commonjs = _path.default.join(output, 'commonjs');
93
- outputs.module = _path.default.join(output, 'module');
94
- } else if (variants.commonjs) {
95
- outputs.commonjs = output;
96
- } else {
97
- outputs.module = output;
98
- }
99
- const outDir = outputs.commonjs ?? outputs.module;
100
- if (outDir == null) {
101
- throw new Error('Neither commonjs nor module output is enabled.');
102
- }
103
- const tsbuildinfo = _path.default.join(outDir, project.replace(/\.json$/, '.tsbuildinfo'));
104
- try {
105
- await (0, _del.deleteAsync)([tsbuildinfo]);
106
- } catch (e) {
107
- // Ignore
108
- }
109
- await (0, _spawn.spawn)(tsc, ['--pretty', '--declaration', '--declarationMap', '--noEmit', 'false', '--emitDeclarationOnly', '--project', project, '--outDir', outDir], {
110
- cwd: root
111
- });
112
- try {
113
- await (0, _del.deleteAsync)([tsbuildinfo]);
114
- } catch (e) {
115
- // Ignore
116
- }
117
- if (esm) {
118
- if (outputs?.commonjs && outputs?.module) {
119
- // When ESM compatible output is enabled and commonjs build is present, we need to generate 2 builds for commonjs and esm
120
- // In this case we copy the already generated types, and add `package.json` with `type` field
121
- await _fsExtra.default.copy(outputs.commonjs, outputs.module);
122
- await _fsExtra.default.writeJSON(_path.default.join(outputs.commonjs, 'package.json'), {
123
- type: 'commonjs'
124
- });
125
- await _fsExtra.default.writeJSON(_path.default.join(outputs.module, 'package.json'), {
126
- type: 'module'
127
- });
128
- } else if (outputs?.commonjs) {
129
- await _fsExtra.default.writeJSON(_path.default.join(outputs.commonjs, 'package.json'), {
130
- type: 'commonjs'
131
- });
132
- } else if (outputs?.module) {
133
- await _fsExtra.default.writeJSON(_path.default.join(outputs.module, 'package.json'), {
134
- type: 'module'
135
- });
136
- }
137
- }
138
- report.success(`Wrote definition files to ${_kleur.default.blue(_path.default.relative(root, output))}`);
139
- const pkg = JSON.parse(await _fsExtra.default.readFile(_path.default.join(root, 'package.json'), 'utf-8'));
140
- const fields = [{
141
- name: 'types',
142
- value: pkg.types,
143
- output: outputs.commonjs,
144
- error: false,
145
- message: undefined
146
- }, ...(pkg.exports?.['.']?.types ? [{
147
- name: "exports['.'].types",
148
- value: pkg.exports?.['.']?.types,
149
- output: outDir,
150
- error: Boolean(pkg.exports?.['.']?.import && pkg.exports?.['.']?.require),
151
- message: `using ${_kleur.default.blue("exports['.'].import")} and ${_kleur.default.blue("exports['.'].require")}. Specify ${_kleur.default.blue("exports['.'].import.types")} and ${_kleur.default.blue("exports['.'].require.types")} instead.`
152
- }] : []), {
153
- name: "exports['.'].import.types",
154
- value: pkg.exports?.['.']?.import?.types,
155
- output: outputs.module,
156
- error: !esm,
157
- message: `the ${_kleur.default.blue('esm')} option is not enabled for the ${_kleur.default.blue('module')} target`
158
- }, {
159
- name: "exports['.'].require.types",
160
- value: pkg.exports?.['.']?.require?.types,
161
- output: outputs.commonjs,
162
- error: false,
163
- message: undefined
164
- }];
165
- const getGeneratedTypesPath = async field => {
166
- if (!field.output || field.error) {
167
- return null;
168
- }
169
- if (pkg.source) {
170
- const indexDTsName = _path.default.basename(pkg.source).replace(/\.(jsx?|tsx?)$/, '') + '.d.ts';
171
- const potentialPaths = [_path.default.join(field.output, _path.default.dirname(pkg.source), indexDTsName), _path.default.join(field.output, _path.default.relative(source, _path.default.join(root, _path.default.dirname(pkg.source))), indexDTsName)];
172
- for (const potentialPath of potentialPaths) {
173
- if (await _fsExtra.default.pathExists(potentialPath)) {
174
- return _path.default.relative(root, potentialPath);
175
- }
176
- }
177
- }
178
- return null;
179
- };
180
- const invalidFieldNames = (await Promise.all(fields.map(async field => {
181
- if (field.error) {
182
- if (field.value) {
183
- report.warn(`The ${_kleur.default.blue(field.name)} field in ${_kleur.default.blue(`package.json`)} should not be set when ${String(field.message)}.`);
184
- }
185
- return null;
186
- }
187
- if (field.name.startsWith('exports') && field.value && !/^\.\//.test(field.value)) {
188
- report.error(`The ${_kleur.default.blue(field.name)} field in ${_kleur.default.blue(`package.json`)} should be a relative path starting with ${_kleur.default.blue('./')}. Found: ${_kleur.default.blue(field.value)}`);
189
- return field.name;
190
- }
191
- if (field.value && !(await _fsExtra.default.pathExists(_path.default.join(root, field.value)))) {
192
- const generatedTypesPath = await getGeneratedTypesPath(field);
193
- report.error(`The ${_kleur.default.blue(field.name)} field in ${_kleur.default.blue('package.json')} points to a non-existent file: ${_kleur.default.blue(field.value)}.\nVerify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}${generatedTypesPath ? ` (found ${_kleur.default.blue(generatedTypesPath)}).` : '.'}`);
194
- return field.name;
195
- }
196
- return null;
197
- }))).filter(name => name != null);
198
- if (invalidFieldNames.length) {
199
- throw new Error(`Found errors for fields: ${invalidFieldNames.join(', ')}.`);
200
- }
201
- const validFields = fields.filter(field => !field.error);
202
- if (validFields.every(field => field.value == null)) {
203
- const suggestedTypesPaths = (await Promise.all(validFields.map(async field => getGeneratedTypesPath(field)))).filter(path => path != null).filter((path, i, self) => self.indexOf(path) === i);
204
- report.warn(`No ${validFields.map(field => _kleur.default.blue(field.name)).join(' or ')} field found in ${_kleur.default.blue('package.json')}. Consider ${suggestedTypesPaths.length ? `pointing to ${suggestedTypesPaths.map(path => _kleur.default.blue(path)).join(' or ')}` : `adding ${validFields.length > 1 ? 'them' : 'it'}`} so that consumers of your package can use the typescript definitions.`);
205
- }
206
- } catch (e) {
207
- if (e != null && typeof e === 'object') {
208
- if ('stdout' in e && e.stdout != null) {
209
- report.error(`Errors found when building definition files:\n${e.stdout.toString()}`);
210
- } else if ('message' in e && typeof e.message === 'string') {
211
- report.error(e.message);
212
- }
213
- }
214
- throw new Error('Failed to build definition files.', {
215
- cause: e
216
- });
217
- }
218
- }
219
- //# sourceMappingURL=typescript.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typescript.js","names":["_del","require","_fsExtra","_interopRequireDefault","_json","_kleur","_os","_path","_which","_spawn","e","__esModule","default","build","source","root","output","report","options","variants","esm","info","kleur","blue","path","relative","deleteAsync","project","tsconfig","join","fs","pathExists","config","JSON5","parse","readFile","compilerOptions","conflicts","declarationDir","push","outDir","length","warn","reduce","acc","curr","gray","yellow","Error","tsc","resolve","execpath","process","env","npm_execpath","cli","split","sep","pop","includes","result","spawn","cwd","FORCE_COLOR","trim","platform","endsWith","which","outputs","commonjs","module","tsbuildinfo","replace","copy","writeJSON","type","success","pkg","JSON","fields","name","value","types","error","message","undefined","exports","Boolean","import","getGeneratedTypesPath","field","indexDTsName","basename","potentialPaths","dirname","potentialPath","invalidFieldNames","Promise","all","map","String","startsWith","test","generatedTypesPath","filter","validFields","every","suggestedTypesPaths","i","self","indexOf","stdout","toString","cause"],"sources":["../../src/targets/typescript.ts"],"sourcesContent":["import { deleteAsync } from 'del';\nimport fs from 'fs-extra';\nimport JSON5 from 'json5';\nimport kleur from 'kleur';\nimport { platform } from 'os';\nimport path from 'path';\nimport which from 'which';\nimport type { Input, Variants } from '../types';\nimport { spawn } from '../utils/spawn';\n\ntype Options = Input & {\n options?: {\n project?: string;\n tsc?: string;\n };\n esm: boolean;\n variants: Variants;\n};\n\ntype Field = {\n name: string;\n value: string | undefined;\n output: string | undefined;\n error: boolean;\n message: string | undefined;\n};\n\nexport default async function build({\n source,\n root,\n output,\n report,\n options,\n variants,\n esm,\n}: Options) {\n report.info(\n `Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`\n );\n\n await deleteAsync([output]);\n\n report.info(`Generating type definitions with ${kleur.blue('tsc')}`);\n\n const project = options?.project ? options.project : 'tsconfig.json';\n const tsconfig = path.join(root, project);\n\n try {\n if (await fs.pathExists(tsconfig)) {\n try {\n const config = JSON5.parse(await fs.readFile(tsconfig, 'utf-8'));\n\n if (config.compilerOptions) {\n const conflicts: string[] = [];\n\n if (config.compilerOptions.declarationDir) {\n conflicts.push('compilerOptions.declarationDir');\n }\n\n if (\n config.compilerOptions.outDir &&\n path.join(root, config.compilerOptions.outDir) !== output\n ) {\n conflicts.push('compilerOptions.outDir');\n }\n\n if (conflicts.length) {\n report.warn(\n `Found following options in the config file which can conflict with the CLI options. Please remove them from ${kleur.blue(\n project\n )}:${conflicts.reduce(\n (acc, curr) =>\n acc + `\\n${kleur.gray('-')} ${kleur.yellow(curr)}`,\n ''\n )}`\n );\n }\n }\n } catch (e) {\n report.warn(\n `Couldn't parse ${kleur.blue(\n project\n )}. There might be validation errors.`\n );\n }\n } else {\n throw new Error(\n `Couldn't find a ${kleur.blue(project)} in the project root.`\n );\n }\n\n let tsc;\n\n if (options?.tsc) {\n tsc = path.resolve(root, options.tsc);\n\n if (!(await fs.pathExists(tsc))) {\n throw new Error(\n `The ${kleur.blue(\n 'tsc'\n )} binary doesn't seem to be installed at ${kleur.blue(\n tsc\n )}. Please specify the correct path in options or remove it to use the workspace's version.`\n );\n }\n } else {\n const execpath = process.env.npm_execpath;\n const cli = execpath?.split(path.sep).pop()?.includes('yarn')\n ? 'yarn'\n : 'npm';\n\n if (cli === 'yarn') {\n const result = await spawn('yarn', ['bin', 'tsc'], {\n cwd: root,\n env: { ...process.env, FORCE_COLOR: '0' },\n });\n\n tsc = result.trim();\n } else {\n tsc = path.resolve(root, 'node_modules', '.bin', 'tsc');\n }\n\n if (platform() === 'win32' && !tsc.endsWith('.cmd')) {\n tsc += '.cmd';\n }\n }\n\n if (!(await fs.pathExists(tsc))) {\n try {\n tsc = await which('tsc');\n\n if (await fs.pathExists(tsc)) {\n report.warn(\n `Failed to locate ${kleur.blue(\n 'tsc'\n )} in the workspace. Falling back to the binary found in ${kleur.blue(\n 'PATH'\n )} at ${kleur.blue(tsc)}. Consider adding ${kleur.blue(\n 'typescript'\n )} to your ${kleur.blue(\n 'devDependencies'\n )} or specifying the ${kleur.blue(\n 'tsc'\n )} option for the typescript target.`\n );\n }\n } catch (e) {\n // Ignore\n }\n }\n\n if (tsc == null || !(await fs.pathExists(tsc))) {\n throw new Error(\n `The ${kleur.blue(\n 'tsc'\n )} binary doesn't seem to be installed under ${kleur.blue(\n 'node_modules'\n )} or present in $PATH. Make sure you have added ${kleur.blue(\n 'typescript'\n )} to your ${kleur.blue('devDependencies')} or specify the ${kleur.blue(\n 'tsc'\n )} option for typescript.`\n );\n }\n\n const outputs: { commonjs?: string; module?: string } = {};\n\n if (esm && variants.commonjs && variants.module) {\n outputs.commonjs = path.join(output, 'commonjs');\n outputs.module = path.join(output, 'module');\n } else if (variants.commonjs) {\n outputs.commonjs = output;\n } else {\n outputs.module = output;\n }\n\n const outDir = outputs.commonjs ?? outputs.module;\n\n if (outDir == null) {\n throw new Error('Neither commonjs nor module output is enabled.');\n }\n\n const tsbuildinfo = path.join(\n outDir,\n project.replace(/\\.json$/, '.tsbuildinfo')\n );\n\n try {\n await deleteAsync([tsbuildinfo]);\n } catch (e) {\n // Ignore\n }\n\n await spawn(\n tsc,\n [\n '--pretty',\n '--declaration',\n '--declarationMap',\n '--noEmit',\n 'false',\n '--emitDeclarationOnly',\n '--project',\n project,\n '--outDir',\n outDir,\n ],\n { cwd: root }\n );\n\n try {\n await deleteAsync([tsbuildinfo]);\n } catch (e) {\n // Ignore\n }\n\n if (esm) {\n if (outputs?.commonjs && outputs?.module) {\n // When ESM compatible output is enabled and commonjs build is present, we need to generate 2 builds for commonjs and esm\n // In this case we copy the already generated types, and add `package.json` with `type` field\n await fs.copy(outputs.commonjs, outputs.module);\n await fs.writeJSON(path.join(outputs.commonjs, 'package.json'), {\n type: 'commonjs',\n });\n await fs.writeJSON(path.join(outputs.module, 'package.json'), {\n type: 'module',\n });\n } else if (outputs?.commonjs) {\n await fs.writeJSON(path.join(outputs.commonjs, 'package.json'), {\n type: 'commonjs',\n });\n } else if (outputs?.module) {\n await fs.writeJSON(path.join(outputs.module, 'package.json'), {\n type: 'module',\n });\n }\n }\n\n report.success(\n `Wrote definition files to ${kleur.blue(path.relative(root, output))}`\n );\n\n const pkg = JSON.parse(\n await fs.readFile(path.join(root, 'package.json'), 'utf-8')\n );\n\n const fields: Field[] = [\n {\n name: 'types',\n value: pkg.types,\n output: outputs.commonjs,\n error: false,\n message: undefined,\n },\n ...(pkg.exports?.['.']?.types\n ? [\n {\n name: \"exports['.'].types\",\n value: pkg.exports?.['.']?.types,\n output: outDir,\n error: Boolean(\n pkg.exports?.['.']?.import && pkg.exports?.['.']?.require\n ),\n message: `using ${kleur.blue(\n \"exports['.'].import\"\n )} and ${kleur.blue(\n \"exports['.'].require\"\n )}. Specify ${kleur.blue(\n \"exports['.'].import.types\"\n )} and ${kleur.blue(\"exports['.'].require.types\")} instead.`,\n },\n ]\n : []),\n {\n name: \"exports['.'].import.types\",\n value: pkg.exports?.['.']?.import?.types,\n output: outputs.module,\n error: !esm,\n message: `the ${kleur.blue(\n 'esm'\n )} option is not enabled for the ${kleur.blue('module')} target`,\n },\n {\n name: \"exports['.'].require.types\",\n value: pkg.exports?.['.']?.require?.types,\n output: outputs.commonjs,\n error: false,\n message: undefined,\n },\n ];\n\n const getGeneratedTypesPath = async (field: Field) => {\n if (!field.output || field.error) {\n return null;\n }\n\n if (pkg.source) {\n const indexDTsName =\n path.basename(pkg.source).replace(/\\.(jsx?|tsx?)$/, '') + '.d.ts';\n\n const potentialPaths = [\n path.join(field.output, path.dirname(pkg.source), indexDTsName),\n path.join(\n field.output,\n path.relative(source, path.join(root, path.dirname(pkg.source))),\n indexDTsName\n ),\n ];\n\n for (const potentialPath of potentialPaths) {\n if (await fs.pathExists(potentialPath)) {\n return path.relative(root, potentialPath);\n }\n }\n }\n\n return null;\n };\n\n const invalidFieldNames = (\n await Promise.all(\n fields.map(async (field) => {\n if (field.error) {\n if (field.value) {\n report.warn(\n `The ${kleur.blue(field.name)} field in ${kleur.blue(\n `package.json`\n )} should not be set when ${String(field.message)}.`\n );\n }\n\n return null;\n }\n\n if (\n field.name.startsWith('exports') &&\n field.value &&\n !/^\\.\\//.test(field.value)\n ) {\n report.error(\n `The ${kleur.blue(field.name)} field in ${kleur.blue(\n `package.json`\n )} should be a relative path starting with ${kleur.blue(\n './'\n )}. Found: ${kleur.blue(field.value)}`\n );\n\n return field.name;\n }\n\n if (\n field.value &&\n !(await fs.pathExists(path.join(root, field.value)))\n ) {\n const generatedTypesPath = await getGeneratedTypesPath(field);\n\n report.error(\n `The ${kleur.blue(field.name)} field in ${kleur.blue(\n 'package.json'\n )} points to a non-existent file: ${kleur.blue(\n field.value\n )}.\\nVerify the path points to the correct file under ${kleur.blue(\n path.relative(root, output)\n )}${\n generatedTypesPath\n ? ` (found ${kleur.blue(generatedTypesPath)}).`\n : '.'\n }`\n );\n\n return field.name;\n }\n\n return null;\n })\n )\n ).filter((name): name is string => name != null);\n\n if (invalidFieldNames.length) {\n throw new Error(\n `Found errors for fields: ${invalidFieldNames.join(', ')}.`\n );\n }\n\n const validFields = fields.filter((field) => !field.error);\n\n if (validFields.every((field) => field.value == null)) {\n const suggestedTypesPaths = (\n await Promise.all(\n validFields.map(async (field) => getGeneratedTypesPath(field))\n )\n )\n .filter((path): path is string => path != null)\n .filter((path, i, self) => self.indexOf(path) === i);\n\n report.warn(\n `No ${validFields\n .map((field) => kleur.blue(field.name))\n .join(' or ')} field found in ${kleur.blue(\n 'package.json'\n )}. Consider ${\n suggestedTypesPaths.length\n ? `pointing to ${suggestedTypesPaths\n .map((path) => kleur.blue(path))\n .join(' or ')}`\n : `adding ${validFields.length > 1 ? 'them' : 'it'}`\n } so that consumers of your package can use the typescript definitions.`\n );\n }\n } catch (e: unknown) {\n if (e != null && typeof e === 'object') {\n if ('stdout' in e && e.stdout != null) {\n report.error(\n `Errors found when building definition files:\\n${e.stdout.toString()}`\n );\n } else if ('message' in e && typeof e.message === 'string') {\n report.error(e.message);\n }\n }\n\n throw new Error('Failed to build definition files.', { cause: e });\n }\n}\n"],"mappings":";;;;;;A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IAAI,KAAKA,IAAI,CAACC,OAAO,CAACtF,IAAI,CAAC,KAAKoF,CAAC,CAAC;MAEtD3F,MAAM,CAACyB,IAAI,CACT,MAAM+D,WAAW,CACdN,GAAG,CAAET,KAAK,IAAKpE,cAAK,CAACC,IAAI,CAACmE,KAAK,CAACV,IAAI,CAAC,CAAC,CACtCnD,IAAI,CAAC,MAAM,CAAC,mBAAmBP,cAAK,CAACC,IAAI,CAC1C,cACF,CAAC,cACCoF,mBAAmB,CAAClE,MAAM,GACtB,eAAekE,mBAAmB,CAC/BR,GAAG,CAAE3E,IAAI,IAAKF,cAAK,CAACC,IAAI,CAACC,IAAI,CAAC,CAAC,CAC/BK,IAAI,CAAC,MAAM,CAAC,EAAE,GACjB,UAAU4E,WAAW,CAAChE,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,wEAE1D,CAAC;IACH;EACF,CAAC,CAAC,OAAO/B,CAAU,EAAE;IACnB,IAAIA,CAAC,IAAI,IAAI,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;MACtC,IAAI,QAAQ,IAAIA,CAAC,IAAIA,CAAC,CAACqG,MAAM,IAAI,IAAI,EAAE;QACrC9F,MAAM,CAACkE,KAAK,CACV,iDAAiDzE,CAAC,CAACqG,MAAM,CAACC,QAAQ,CAAC,CAAC,EACtE,CAAC;MACH,CAAC,MAAM,IAAI,SAAS,IAAItG,CAAC,IAAI,OAAOA,CAAC,CAAC0E,OAAO,KAAK,QAAQ,EAAE;QAC1DnE,MAAM,CAACkE,KAAK,CAACzE,CAAC,CAAC0E,OAAO,CAAC;MACzB;IACF;IAEA,MAAM,IAAIpC,KAAK,CAAC,mCAAmC,EAAE;MAAEiE,KAAK,EAAEvG;IAAE,CAAC,CAAC;EACpE;AACF","ignoreList":[]}
package/lib/types.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=types.js.map
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type Log = (message: string) => void;\n\nexport type Report = {\n info: Log;\n warn: Log;\n success: Log;\n error: Log;\n};\n\nexport type Input = {\n root: string;\n source: string;\n output: string;\n report: Report;\n};\n\nexport type Variants = {\n commonjs?: boolean;\n module?: boolean;\n};\n\ndeclare module '@babel/core' {\n export interface TransformCaller {\n rewriteImportExtensions: boolean;\n jsxRuntime: 'automatic' | 'classic';\n codegenEnabled: boolean;\n }\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = androidAssemble;
7
- var _path = _interopRequireDefault(require("path"));
8
- var _kleur = _interopRequireDefault(require("kleur"));
9
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
10
- var _child_process = require("child_process");
11
- var _os = require("os");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- async function androidAssemble({
14
- root,
15
- androidPath,
16
- report
17
- }) {
18
- const cwd = _path.default.relative(root, androidPath);
19
- report.info(`Assembling Android project in ${_kleur.default.blue(cwd)} with ${_kleur.default.blue('gradle')}`);
20
- const gradleWrapper = (0, _os.platform)() === 'win32' ? 'gradlew.bat' : './gradlew';
21
- if (await _fsExtra.default.pathExists(_path.default.join(androidPath, gradleWrapper))) {
22
- (0, _child_process.execFileSync)(gradleWrapper, ['assemble'], {
23
- cwd: androidPath
24
- });
25
- } else {
26
- throw new Error(`The ${_kleur.default.blue('gradlew')} script doesn't seem to present in ${_kleur.default.blue(androidPath)}. Make sure you have added it by running ${_kleur.default.blue('gradle wrapper')} in that directory.`);
27
- }
28
- }
29
- //# sourceMappingURL=androidAssemble.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"androidAssemble.js","names":["_path","_interopRequireDefault","require","_kleur","_fsExtra","_child_process","_os","e","__esModule","default","androidAssemble","root","androidPath","report","cwd","path","relative","info","kleur","blue","gradleWrapper","platform","fs","pathExists","join","execFileSync","Error"],"sources":["../../src/utils/androidAssemble.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport fs from 'fs-extra';\nimport { execFileSync } from 'child_process';\nimport { platform } from 'os';\nimport type { Report } from '../types';\n\ntype Options = {\n root: string;\n androidPath: string;\n report: Report;\n};\n\nexport default async function androidAssemble({\n root,\n androidPath,\n report,\n}: Options) {\n const cwd = path.relative(root, androidPath);\n\n report.info(\n `Assembling Android project in ${kleur.blue(cwd)} with ${kleur.blue(\n 'gradle'\n )}`\n );\n\n const gradleWrapper = platform() === 'win32' ? 'gradlew.bat' : './gradlew';\n\n if (await fs.pathExists(path.join(androidPath, gradleWrapper))) {\n execFileSync(gradleWrapper, ['assemble'], { cwd: androidPath });\n } else {\n throw new Error(\n `The ${kleur.blue(\n 'gradlew'\n )} script doesn't seem to present in ${kleur.blue(\n androidPath\n )}. Make sure you have added it by running ${kleur.blue(\n 'gradle wrapper'\n )} in that directory.`\n );\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,GAAA,GAAAJ,OAAA;AAA8B,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASf,eAAeG,eAAeA,CAAC;EAC5CC,IAAI;EACJC,WAAW;EACXC;AACO,CAAC,EAAE;EACV,MAAMC,GAAG,GAAGC,aAAI,CAACC,QAAQ,CAACL,IAAI,EAAEC,WAAW,CAAC;EAE5CC,MAAM,CAACI,IAAI,CACT,iCAAiCC,cAAK,CAACC,IAAI,CAACL,GAAG,CAAC,SAASI,cAAK,CAACC,IAAI,CACjE,QACF,CAAC,EACH,CAAC;EAED,MAAMC,aAAa,GAAG,IAAAC,YAAQ,EAAC,CAAC,KAAK,OAAO,GAAG,aAAa,GAAG,WAAW;EAE1E,IAAI,MAAMC,gBAAE,CAACC,UAAU,CAACR,aAAI,CAACS,IAAI,CAACZ,WAAW,EAAEQ,aAAa,CAAC,CAAC,EAAE;IAC9D,IAAAK,2BAAY,EAACL,aAAa,EAAE,CAAC,UAAU,CAAC,EAAE;MAAEN,GAAG,EAAEF;IAAY,CAAC,CAAC;EACjE,CAAC,MAAM;IACL,MAAM,IAAIc,KAAK,CACb,OAAOR,cAAK,CAACC,IAAI,CACf,SACF,CAAC,sCAAsCD,cAAK,CAACC,IAAI,CAC/CP,WACF,CAAC,4CAA4CM,cAAK,CAACC,IAAI,CACrD,gBACF,CAAC,qBACH,CAAC;EACH;AACF","ignoreList":[]}
@@ -1,217 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = compile;
7
- var _path = _interopRequireDefault(require("path"));
8
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
- var _kleur = _interopRequireDefault(require("kleur"));
10
- var babel = _interopRequireWildcard(require("@babel/core"));
11
- var _glob = require("glob");
12
- var _isCodegenSpec = require("./isCodegenSpec");
13
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- const sourceExt = /\.([cm])?[jt]sx?$/;
16
- async function compile({
17
- root,
18
- source,
19
- output,
20
- esm = false,
21
- babelrc = false,
22
- configFile = false,
23
- exclude,
24
- modules,
25
- copyFlow,
26
- sourceMaps = true,
27
- report,
28
- jsxRuntime = 'automatic',
29
- variants
30
- }) {
31
- const files = (0, _glob.globSync)('**/*', {
32
- cwd: source,
33
- absolute: true,
34
- nodir: true,
35
- ignore: exclude
36
- });
37
- report.info(`Compiling ${_kleur.default.blue(String(files.length))} files in ${_kleur.default.blue(_path.default.relative(root, source))} with ${_kleur.default.blue('babel')}`);
38
- const pkg = JSON.parse(await _fsExtra.default.readFile(_path.default.join(root, 'package.json'), 'utf-8'));
39
- if (copyFlow) {
40
- if (!Object.keys(pkg.devDependencies || {}).includes('flow-bin')) {
41
- report.warn(`The ${_kleur.default.blue('copyFlow')} option was specified, but couldn't find ${_kleur.default.blue('flow-bin')} in ${_kleur.default.blue('package.json')}.\nIf the project is using ${_kleur.default.blue('flow')}, then make sure you have added ${_kleur.default.blue('flow-bin')} to your ${_kleur.default.blue('devDependencies')}, otherwise remove the ${_kleur.default.blue('copyFlow')} option.`);
42
- }
43
- }
44
- await _fsExtra.default.mkdirp(output);
45
-
46
- // Imports are not rewritten to include the extension if `esm` is not enabled
47
- // Ideally we should always treat ESM syntax as CommonJS if `esm` is not enabled
48
- // This would maintain compatibility for legacy setups where `import`/`export` didn't require file extensions
49
- // However NextJS has non-standard behavior and breaks if we add `type: 'commonjs'` for code with import/export
50
- // So we skip generating `package.json` if `esm` is not enabled and `modules` is not `commonjs`
51
- // This means that user can't use `type: 'module'` in root `package.json` without enabling `esm` for `module` target
52
- if (esm || modules === 'commonjs') {
53
- await _fsExtra.default.writeJSON(_path.default.join(output, 'package.json'), {
54
- type: modules === 'commonjs' ? 'commonjs' : 'module'
55
- });
56
- }
57
- await Promise.all(files.map(async filepath => {
58
- const outputFilename = _path.default.join(output, _path.default.relative(source, filepath)).replace(sourceExt, '.$1js');
59
- await _fsExtra.default.mkdirp(_path.default.dirname(outputFilename));
60
- if (!sourceExt.test(filepath)) {
61
- // Copy files which aren't source code
62
- await _fsExtra.default.copy(filepath, outputFilename);
63
- return;
64
- }
65
- const content = await _fsExtra.default.readFile(filepath, 'utf-8');
66
-
67
- // If codegen is used in the app, then we need to preserve TypeScript source
68
- // So we copy the file as is instead of transforming it
69
- const codegenEnabled = 'codegenConfig' in pkg;
70
- if (codegenEnabled && (0, _isCodegenSpec.isCodegenSpec)(filepath)) {
71
- await _fsExtra.default.copy(filepath, _path.default.join(output, _path.default.relative(source, filepath)));
72
- return;
73
- }
74
- const result = await babel.transformAsync(content, {
75
- caller: {
76
- name: 'react-native-builder-bob',
77
- supportsStaticESM: /\.m[jt]s$/.test(filepath) ||
78
- // If a file is explicitly marked as ESM, then preserve the syntax
79
- modules === 'preserve' ? true : false,
80
- rewriteImportExtensions: esm,
81
- jsxRuntime,
82
- codegenEnabled
83
- },
84
- cwd: root,
85
- babelrc: babelrc,
86
- configFile: configFile,
87
- sourceMaps,
88
- sourceRoot: _path.default.relative(_path.default.dirname(outputFilename), source),
89
- sourceFileName: _path.default.relative(source, filepath),
90
- filename: filepath,
91
- ...(babelrc || configFile ? null : {
92
- presets: [require.resolve('../../configs/babel-preset')]
93
- })
94
- });
95
- if (result == null) {
96
- throw new Error('Output code was null');
97
- }
98
- let code = result.code || '';
99
- if (sourceMaps && result.map) {
100
- const mapFilename = outputFilename + '.map';
101
- code += '\n//# sourceMappingURL=' + _path.default.basename(mapFilename);
102
-
103
- // Don't inline the source code, it can be retrieved from the source file
104
- result.map.sourcesContent = undefined;
105
- await _fsExtra.default.writeJSON(mapFilename, result.map);
106
- }
107
- await _fsExtra.default.writeFile(outputFilename, code);
108
- if (copyFlow) {
109
- await _fsExtra.default.copy(filepath, outputFilename + '.flow');
110
- }
111
- }));
112
- report.success(`Wrote files to ${_kleur.default.blue(_path.default.relative(root, output))}`);
113
- const getGeneratedEntryPath = async () => {
114
- if (pkg.source) {
115
- for (const ext of ['.js', '.cjs', '.mjs']) {
116
- const indexName =
117
- // The source field may not have an extension, so we add it instead of replacing directly
118
- _path.default.basename(pkg.source).replace(sourceExt, '') + ext;
119
- const potentialPath = _path.default.join(output, _path.default.dirname(_path.default.relative(source, _path.default.join(root, pkg.source))), indexName);
120
- if (await _fsExtra.default.pathExists(potentialPath)) {
121
- return _path.default.relative(root, potentialPath);
122
- }
123
- }
124
- }
125
- return null;
126
- };
127
- const fields = [];
128
- if (variants.commonjs && variants.module) {
129
- if (modules === 'commonjs') {
130
- fields.push({
131
- name: 'main',
132
- value: pkg.main
133
- });
134
- } else {
135
- fields.push({
136
- name: 'module',
137
- value: pkg.module
138
- });
139
- }
140
- } else {
141
- fields.push({
142
- name: 'main',
143
- value: pkg.main
144
- });
145
- }
146
- if (esm) {
147
- if (variants.commonjs && variants.module) {
148
- if (modules === 'commonjs') {
149
- fields.push(typeof pkg.exports?.['.']?.require === 'string' ? {
150
- name: "exports['.'].require",
151
- value: pkg.exports?.['.']?.require
152
- } : {
153
- name: "exports['.'].require.default",
154
- value: pkg.exports?.['.']?.require?.default
155
- });
156
- } else {
157
- fields.push(typeof pkg.exports?.['.']?.import === 'string' ? {
158
- name: "exports['.'].import",
159
- value: pkg.exports?.['.']?.import
160
- } : {
161
- name: "exports['.'].import.default",
162
- value: pkg.exports?.['.']?.import?.default
163
- });
164
- }
165
- } else {
166
- fields.push({
167
- name: "exports['.'].default",
168
- value: pkg.exports?.['.']?.default
169
- });
170
- }
171
- } else {
172
- if (modules === 'commonjs' && pkg.exports?.['.']?.require) {
173
- report.warn(`The ${_kleur.default.blue('esm')} option is disabled, but the ${_kleur.default.blue("exports['.'].require")} field is set in ${_kleur.default.blue('package.json')}. This is likely a mistake.`);
174
- } else if (modules === 'preserve' && pkg.exports?.['.']?.import) {
175
- report.warn(`The ${_kleur.default.blue('esm')} option is disabled, but the ${_kleur.default.blue("exports['.'].import")} field is set in ${_kleur.default.blue('package.json')}. This is likely a mistake.`);
176
- }
177
- }
178
- const generatedEntryPath = await getGeneratedEntryPath();
179
- if (fields.some(field => field.value)) {
180
- for (const {
181
- name,
182
- value
183
- } of fields) {
184
- if (!value) {
185
- continue;
186
- }
187
- if (name.startsWith('exports') && value && !/^\.\//.test(value)) {
188
- report.error(`The ${_kleur.default.blue(name)} field in ${_kleur.default.blue(`package.json`)} should be a relative path starting with ${_kleur.default.blue('./')}. Found: ${_kleur.default.blue(value)}`);
189
- throw new Error(`Found incorrect path in '${name}' field.`);
190
- }
191
- try {
192
- require.resolve(_path.default.join(root, value));
193
- } catch (e) {
194
- if (e != null && typeof e === 'object' && 'code' in e && e.code === 'MODULE_NOT_FOUND') {
195
- if (!generatedEntryPath) {
196
- report.warn(`Failed to detect the entry point for the generated files. Make sure you have a valid ${_kleur.default.blue('source')} field in your ${_kleur.default.blue('package.json')}.`);
197
- }
198
- report.error(`The ${_kleur.default.blue(name)} field in ${_kleur.default.blue('package.json')} points to a non-existent file: ${_kleur.default.blue(value)}.\nVerify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}${generatedEntryPath ? ` (found ${_kleur.default.blue(generatedEntryPath)}).` : '.'}`);
199
- throw new Error(`Found incorrect path in '${name}' field.`, {
200
- cause: e
201
- });
202
- }
203
- throw e;
204
- }
205
- }
206
- if (generatedEntryPath) {
207
- if (modules === 'commonjs' && pkg.exports?.['.']?.import === `./${generatedEntryPath}`) {
208
- report.warn(`The the ${_kleur.default.blue("exports['.'].import")} field points to a CommonJS module. This is likely a mistake.`);
209
- } else if (modules === 'preserve' && pkg.exports?.['.']?.require === `./${generatedEntryPath}`) {
210
- report.warn(`The the ${_kleur.default.blue("exports['.'].import")} field points to a ES module. This is likely a mistake.`);
211
- }
212
- }
213
- } else {
214
- report.warn(`No ${fields.map(field => _kleur.default.blue(field.name)).join(' or ')} field found in ${_kleur.default.blue('package.json')}. Consider ${generatedEntryPath ? `pointing to ${_kleur.default.blue(generatedEntryPath)}` : `adding ${fields.length > 1 ? 'them' : 'it'}`} so that consumers of your package can import your package.`);
215
- }
216
- }
217
- //# sourceMappingURL=compile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compile.js","names":["_path","_interopRequireDefault","require","_fsExtra","_kleur","babel","_interopRequireWildcard","_glob","_isCodegenSpec","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","sourceExt","compile","root","source","output","esm","babelrc","configFile","exclude","modules","copyFlow","sourceMaps","report","jsxRuntime","variants","files","globSync","cwd","absolute","nodir","ignore","info","kleur","blue","String","length","path","relative","pkg","JSON","parse","fs","readFile","join","keys","devDependencies","includes","warn","mkdirp","writeJSON","type","Promise","all","map","filepath","outputFilename","replace","dirname","test","copy","content","codegenEnabled","isCodegenSpec","result","transformAsync","caller","name","supportsStaticESM","rewriteImportExtensions","sourceRoot","sourceFileName","filename","presets","resolve","Error","code","mapFilename","basename","sourcesContent","undefined","writeFile","success","getGeneratedEntryPath","ext","indexName","potentialPath","pathExists","fields","commonjs","module","push","value","main","exports","import","generatedEntryPath","some","field","startsWith","error","cause"],"sources":["../../src/utils/compile.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport kleur from 'kleur';\nimport * as babel from '@babel/core';\nimport { globSync } from 'glob';\nimport type { Input, Variants } from '../types';\nimport { isCodegenSpec } from './isCodegenSpec';\n\nexport type CompileOptions = {\n esm?: boolean;\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n jsxRuntime?: 'automatic' | 'classic';\n};\n\ntype Options = Input &\n CompileOptions & {\n modules: 'commonjs' | 'preserve';\n variants: Variants;\n exclude: string;\n };\n\nconst sourceExt = /\\.([cm])?[jt]sx?$/;\n\nexport default async function compile({\n root,\n source,\n output,\n esm = false,\n babelrc = false,\n configFile = false,\n exclude,\n modules,\n copyFlow,\n sourceMaps = true,\n report,\n jsxRuntime = 'automatic',\n variants,\n}: Options) {\n const files = globSync('**/*', {\n cwd: source,\n absolute: true,\n nodir: true,\n ignore: exclude,\n });\n\n report.info(\n `Compiling ${kleur.blue(String(files.length))} files in ${kleur.blue(\n path.relative(root, source)\n )} with ${kleur.blue('babel')}`\n );\n\n const pkg = JSON.parse(\n await fs.readFile(path.join(root, 'package.json'), 'utf-8')\n );\n\n if (copyFlow) {\n if (!Object.keys(pkg.devDependencies || {}).includes('flow-bin')) {\n report.warn(\n `The ${kleur.blue(\n 'copyFlow'\n )} option was specified, but couldn't find ${kleur.blue(\n 'flow-bin'\n )} in ${kleur.blue(\n 'package.json'\n )}.\\nIf the project is using ${kleur.blue(\n 'flow'\n )}, then make sure you have added ${kleur.blue(\n 'flow-bin'\n )} to your ${kleur.blue(\n 'devDependencies'\n )}, otherwise remove the ${kleur.blue('copyFlow')} option.`\n );\n }\n }\n\n await fs.mkdirp(output);\n\n // Imports are not rewritten to include the extension if `esm` is not enabled\n // Ideally we should always treat ESM syntax as CommonJS if `esm` is not enabled\n // This would maintain compatibility for legacy setups where `import`/`export` didn't require file extensions\n // However NextJS has non-standard behavior and breaks if we add `type: 'commonjs'` for code with import/export\n // So we skip generating `package.json` if `esm` is not enabled and `modules` is not `commonjs`\n // This means that user can't use `type: 'module'` in root `package.json` without enabling `esm` for `module` target\n if (esm || modules === 'commonjs') {\n await fs.writeJSON(path.join(output, 'package.json'), {\n type: modules === 'commonjs' ? 'commonjs' : 'module',\n });\n }\n\n await Promise.all(\n files.map(async (filepath) => {\n const outputFilename = path\n .join(output, path.relative(source, filepath))\n .replace(sourceExt, '.$1js');\n\n await fs.mkdirp(path.dirname(outputFilename));\n\n if (!sourceExt.test(filepath)) {\n // Copy files which aren't source code\n await fs.copy(filepath, outputFilename);\n return;\n }\n\n const content = await fs.readFile(filepath, 'utf-8');\n\n // If codegen is used in the app, then we need to preserve TypeScript source\n // So we copy the file as is instead of transforming it\n const codegenEnabled = 'codegenConfig' in pkg;\n\n if (codegenEnabled && isCodegenSpec(filepath)) {\n await fs.copy(\n filepath,\n path.join(output, path.relative(source, filepath))\n );\n return;\n }\n\n const result = await babel.transformAsync(content, {\n caller: {\n name: 'react-native-builder-bob',\n supportsStaticESM:\n /\\.m[jt]s$/.test(filepath) || // If a file is explicitly marked as ESM, then preserve the syntax\n modules === 'preserve'\n ? true\n : false,\n rewriteImportExtensions: esm,\n jsxRuntime,\n codegenEnabled,\n },\n cwd: root,\n babelrc: babelrc,\n configFile: configFile,\n sourceMaps,\n sourceRoot: path.relative(path.dirname(outputFilename), source),\n sourceFileName: path.relative(source, filepath),\n filename: filepath,\n ...(babelrc || configFile\n ? null\n : {\n presets: [require.resolve('../../configs/babel-preset')],\n }),\n });\n\n if (result == null) {\n throw new Error('Output code was null');\n }\n\n let code = result.code || '';\n\n if (sourceMaps && result.map) {\n const mapFilename = outputFilename + '.map';\n\n code += '\\n//# sourceMappingURL=' + path.basename(mapFilename);\n\n // Don't inline the source code, it can be retrieved from the source file\n result.map.sourcesContent = undefined;\n\n await fs.writeJSON(mapFilename, result.map);\n }\n\n await fs.writeFile(outputFilename, code);\n\n if (copyFlow) {\n await fs.copy(filepath, outputFilename + '.flow');\n }\n })\n );\n\n report.success(`Wrote files to ${kleur.blue(path.relative(root, output))}`);\n\n const getGeneratedEntryPath = async () => {\n if (pkg.source) {\n for (const ext of ['.js', '.cjs', '.mjs']) {\n const indexName =\n // The source field may not have an extension, so we add it instead of replacing directly\n path.basename(pkg.source).replace(sourceExt, '') + ext;\n\n const potentialPath = path.join(\n output,\n path.dirname(path.relative(source, path.join(root, pkg.source))),\n indexName\n );\n\n if (await fs.pathExists(potentialPath)) {\n return path.relative(root, potentialPath);\n }\n }\n }\n\n return null;\n };\n\n const fields: { name: string; value: string | undefined }[] = [];\n\n if (variants.commonjs && variants.module) {\n if (modules === 'commonjs') {\n fields.push({ name: 'main', value: pkg.main });\n } else {\n fields.push({ name: 'module', value: pkg.module });\n }\n } else {\n fields.push({ name: 'main', value: pkg.main });\n }\n\n if (esm) {\n if (variants.commonjs && variants.module) {\n if (modules === 'commonjs') {\n fields.push(\n typeof pkg.exports?.['.']?.require === 'string'\n ? {\n name: \"exports['.'].require\",\n value: pkg.exports?.['.']?.require,\n }\n : {\n name: \"exports['.'].require.default\",\n value: pkg.exports?.['.']?.require?.default,\n }\n );\n } else {\n fields.push(\n typeof pkg.exports?.['.']?.import === 'string'\n ? {\n name: \"exports['.'].import\",\n value: pkg.exports?.['.']?.import,\n }\n : {\n name: \"exports['.'].import.default\",\n value: pkg.exports?.['.']?.import?.default,\n }\n );\n }\n } else {\n fields.push({\n name: \"exports['.'].default\",\n value: pkg.exports?.['.']?.default,\n });\n }\n } else {\n if (modules === 'commonjs' && pkg.exports?.['.']?.require) {\n report.warn(\n `The ${kleur.blue('esm')} option is disabled, but the ${kleur.blue(\n \"exports['.'].require\"\n )} field is set in ${kleur.blue(\n 'package.json'\n )}. This is likely a mistake.`\n );\n } else if (modules === 'preserve' && pkg.exports?.['.']?.import) {\n report.warn(\n `The ${kleur.blue('esm')} option is disabled, but the ${kleur.blue(\n \"exports['.'].import\"\n )} field is set in ${kleur.blue(\n 'package.json'\n )}. This is likely a mistake.`\n );\n }\n }\n\n const generatedEntryPath = await getGeneratedEntryPath();\n\n if (fields.some((field) => field.value)) {\n for (const { name, value } of fields) {\n if (!value) {\n continue;\n }\n\n if (name.startsWith('exports') && value && !/^\\.\\//.test(value)) {\n report.error(\n `The ${kleur.blue(name)} field in ${kleur.blue(\n `package.json`\n )} should be a relative path starting with ${kleur.blue(\n './'\n )}. Found: ${kleur.blue(value)}`\n );\n\n throw new Error(`Found incorrect path in '${name}' field.`);\n }\n\n try {\n require.resolve(path.join(root, value));\n } catch (e: unknown) {\n if (\n e != null &&\n typeof e === 'object' &&\n 'code' in e &&\n e.code === 'MODULE_NOT_FOUND'\n ) {\n if (!generatedEntryPath) {\n report.warn(\n `Failed to detect the entry point for the generated files. Make sure you have a valid ${kleur.blue(\n 'source'\n )} field in your ${kleur.blue('package.json')}.`\n );\n }\n\n report.error(\n `The ${kleur.blue(name)} field in ${kleur.blue(\n 'package.json'\n )} points to a non-existent file: ${kleur.blue(\n value\n )}.\\nVerify the path points to the correct file under ${kleur.blue(\n path.relative(root, output)\n )}${\n generatedEntryPath\n ? ` (found ${kleur.blue(generatedEntryPath)}).`\n : '.'\n }`\n );\n\n throw new Error(`Found incorrect path in '${name}' field.`, {\n cause: e,\n });\n }\n\n throw e;\n }\n }\n\n if (generatedEntryPath) {\n if (\n modules === 'commonjs' &&\n pkg.exports?.['.']?.import === `./${generatedEntryPath}`\n ) {\n report.warn(\n `The the ${kleur.blue(\n \"exports['.'].import\"\n )} field points to a CommonJS module. This is likely a mistake.`\n );\n } else if (\n modules === 'preserve' &&\n pkg.exports?.['.']?.require === `./${generatedEntryPath}`\n ) {\n report.warn(\n `The the ${kleur.blue(\n \"exports['.'].import\"\n )} field points to a ES module. This is likely a mistake.`\n );\n }\n }\n } else {\n report.warn(\n `No ${fields\n .map((field) => kleur.blue(field.name))\n .join(' or ')} field found in ${kleur.blue('package.json')}. Consider ${\n generatedEntryPath\n ? `pointing to ${kleur.blue(generatedEntryPath)}`\n : `adding ${fields.length > 1 ? 'them' : 'it'}`\n } so that consumers of your package can import your package.`\n );\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,cAAA,GAAAN,OAAA;AAAgD,SAAAI,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,U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AAM,CAACyB,IAAI,CACT,WAAWf,cAAK,CAACC,IAAI,CACnB,qBACF,CAAC,yDACH,CAAC;MACH;IACF;EACF,CAAC,MAAM;IACLX,MAAM,CAACyB,IAAI,CACT,MAAMwC,MAAM,CACTlC,GAAG,CAAE4C,KAAK,IAAKjE,cAAK,CAACC,IAAI,CAACgE,KAAK,CAAC/B,IAAI,CAAC,CAAC,CACtCvB,IAAI,CAAC,MAAM,CAAC,mBAAmBX,cAAK,CAACC,IAAI,CAAC,cAAc,CAAC,cAC1D8D,kBAAkB,GACd,eAAe/D,cAAK,CAACC,IAAI,CAAC8D,kBAAkB,CAAC,EAAE,GAC/C,UAAUR,MAAM,CAACpD,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,6DAErD,CAAC;EACH;AACF","ignoreList":[]}
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isCodegenSpec = isCodegenSpec;
7
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- function isCodegenSpec(filepath) {
10
- const looksLikeCodgenSpec = /(?:^|[\\/])(?:(\w+)NativeComponent)\.[jt]sx?$/i.test(filepath);
11
- if (looksLikeCodgenSpec) {
12
- // This is used in the babel plugin so needs to be synchronous
13
- const content = _fsExtra.default.readFileSync(filepath, 'utf8');
14
-
15
- // Regex taken from https://github.com/facebook/react-native/blob/271232d85654cee32322b1c8a3a39ef647ad02e2/packages/react-native-babel-preset/src/configs/main.js#L78C24-L78C47
16
- if (/\bcodegenNativeComponent</.test(content)) {
17
- return true;
18
- }
19
- }
20
- return false;
21
- }
22
- //# sourceMappingURL=isCodegenSpec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isCodegenSpec.js","names":["_fsExtra","_interopRequireDefault","require","e","__esModule","default","isCodegenSpec","filepath","looksLikeCodgenSpec","test","content","fs","readFileSync"],"sources":["../../src/utils/isCodegenSpec.ts"],"sourcesContent":["import fs from 'fs-extra';\n\nexport function isCodegenSpec(filepath: string): boolean {\n const looksLikeCodgenSpec =\n /(?:^|[\\\\/])(?:(\\w+)NativeComponent)\\.[jt]sx?$/i.test(filepath);\n\n if (looksLikeCodgenSpec) {\n // This is used in the babel plugin so needs to be synchronous\n const content = fs.readFileSync(filepath, 'utf8');\n\n // Regex taken from https://github.com/facebook/react-native/blob/271232d85654cee32322b1c8a3a39ef647ad02e2/packages/react-native-babel-preset/src/configs/main.js#L78C24-L78C47\n if (/\\bcodegenNativeComponent</.test(content)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnB,SAASG,aAAaA,CAACC,QAAgB,EAAW;EACvD,MAAMC,mBAAmB,GACvB,gDAAgD,CAACC,IAAI,CAACF,QAAQ,CAAC;EAEjE,IAAIC,mBAAmB,EAAE;IACvB;IACA,MAAME,OAAO,GAAGC,gBAAE,CAACC,YAAY,CAACL,QAAQ,EAAE,MAAM,CAAC;;IAEjD;IACA,IAAI,2BAA2B,CAACE,IAAI,CAACC,OAAO,CAAC,EAAE;MAC7C,OAAO,IAAI;IACb;EACF;EAEA,OAAO,KAAK;AACd","ignoreList":[]}