react-native-builder-bob 0.38.1 → 0.38.3

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 (39) hide show
  1. package/lib/__fixtures__/project/MyNativeComponent.js +2 -0
  2. package/lib/__fixtures__/project/MyNativeComponent.js.map +1 -0
  3. package/lib/__fixtures__/project/NativeMyLib.js +2 -0
  4. package/lib/__fixtures__/project/NativeMyLib.js.map +1 -0
  5. package/lib/__fixtures__/project/code/$exports-input.js +10 -10
  6. package/lib/__fixtures__/project/code/$exports-input.js.map +1 -1
  7. package/lib/__fixtures__/project/code/$exports-output.js +10 -10
  8. package/lib/__fixtures__/project/code/$exports-output.js.map +1 -1
  9. package/lib/__fixtures__/project/code/$imports-input.js +10 -10
  10. package/lib/__fixtures__/project/code/$imports-input.js.map +1 -1
  11. package/lib/__fixtures__/project/code/$imports-output.js +10 -10
  12. package/lib/__fixtures__/project/code/$imports-output.js.map +1 -1
  13. package/lib/__fixtures__/project/code/MyNativeComponent.js +2 -0
  14. package/lib/__fixtures__/project/code/MyNativeComponent.js.map +1 -0
  15. package/lib/__fixtures__/project/code/NativeMyLib.js +2 -0
  16. package/lib/__fixtures__/project/code/NativeMyLib.js.map +1 -0
  17. package/lib/__tests__/{index.test.js → babel.test.js} +8 -1
  18. package/lib/__tests__/babel.test.js.map +1 -0
  19. package/lib/__tests__/init.test.js +82 -0
  20. package/lib/__tests__/init.test.js.map +1 -0
  21. package/lib/build.js +163 -0
  22. package/lib/build.js.map +1 -0
  23. package/lib/index.js +3 -433
  24. package/lib/index.js.map +1 -1
  25. package/lib/init.js +371 -0
  26. package/lib/init.js.map +1 -0
  27. package/lib/targets/commonjs.js +2 -0
  28. package/lib/targets/commonjs.js.map +1 -1
  29. package/lib/targets/module.js +2 -0
  30. package/lib/targets/module.js.map +1 -1
  31. package/lib/targets/typescript.js +48 -25
  32. package/lib/targets/typescript.js.map +1 -1
  33. package/lib/types.js.map +1 -1
  34. package/lib/utils/compile.js +50 -25
  35. package/lib/utils/compile.js.map +1 -1
  36. package/lib/utils/loadConfig.js +21 -0
  37. package/lib/utils/loadConfig.js.map +1 -0
  38. package/package.json +4 -3
  39. package/lib/__tests__/index.test.js.map +0 -1
package/lib/init.js ADDED
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.init = init;
7
+ var _path = _interopRequireDefault(require("path"));
8
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
+ var _kleur = _interopRequireDefault(require("kleur"));
10
+ var _dedent = _interopRequireDefault(require("dedent"));
11
+ var _isGitDirty = _interopRequireDefault(require("is-git-dirty"));
12
+ var _prompts = _interopRequireDefault(require("./utils/prompts"));
13
+ var logger = _interopRequireWildcard(require("./utils/logger"));
14
+ var _loadConfig = require("./utils/loadConfig");
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ // eslint-disable-next-line import/no-commonjs, @typescript-eslint/no-var-requires
19
+ const {
20
+ name,
21
+ version
22
+ } = require('../package.json');
23
+ const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m;
24
+ async function init() {
25
+ const root = process.cwd();
26
+ const projectPackagePath = _path.default.resolve(root, 'package.json');
27
+ if ((0, _isGitDirty.default)()) {
28
+ const {
29
+ shouldContinue
30
+ } = await (0, _prompts.default)({
31
+ type: 'confirm',
32
+ name: 'shouldContinue',
33
+ message: `The working directory is not clean.\n You should commit or stash your changes before configuring bob.\n Continue anyway?`,
34
+ initial: false
35
+ });
36
+ if (!shouldContinue) {
37
+ process.exit(0);
38
+ }
39
+ }
40
+ if (!(await _fsExtra.default.pathExists(projectPackagePath))) {
41
+ logger.error(`Couldn't find a 'package.json' file in '${root}'.\n Are you in a project folder?`);
42
+ process.exit(1);
43
+ }
44
+ const pkg = JSON.parse(await _fsExtra.default.readFile(projectPackagePath, 'utf-8'));
45
+ const result = await (0, _loadConfig.loadConfig)();
46
+ if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {
47
+ const {
48
+ shouldContinue
49
+ } = await (0, _prompts.default)({
50
+ type: 'confirm',
51
+ name: 'shouldContinue',
52
+ message: `The project seems to be already configured with bob.\n Do you want to overwrite the existing configuration?`,
53
+ initial: false
54
+ });
55
+ if (!shouldContinue) {
56
+ process.exit(0);
57
+ }
58
+ }
59
+ const {
60
+ source
61
+ } = await (0, _prompts.default)({
62
+ type: 'text',
63
+ name: 'source',
64
+ message: 'Where are your source files?',
65
+ initial: 'src',
66
+ validate: input => Boolean(input)
67
+ });
68
+ let entryFile;
69
+ if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.js'))) {
70
+ entryFile = 'index.js';
71
+ } else if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.ts'))) {
72
+ entryFile = 'index.ts';
73
+ } else if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.tsx'))) {
74
+ entryFile = 'index.tsx';
75
+ }
76
+ if (!entryFile) {
77
+ logger.error(`Couldn't find a 'index.js'. 'index.ts' or 'index.tsx' file under '${source}'.\n Please re-run the CLI after creating it.`);
78
+ process.exit(1);
79
+ }
80
+ pkg.devDependencies = Object.fromEntries([...Object.entries(pkg.devDependencies || {}), [name, `^${version}`]].sort(([a], [b]) => a.localeCompare(b)));
81
+ const questions = [{
82
+ type: 'text',
83
+ name: 'output',
84
+ message: 'Where do you want to generate the output files?',
85
+ initial: 'lib',
86
+ validate: input => Boolean(input)
87
+ }, {
88
+ type: 'multiselect',
89
+ name: 'targets',
90
+ message: 'Which targets do you want to build?',
91
+ choices: [{
92
+ title: 'module - for modern setups',
93
+ value: 'module',
94
+ selected: true
95
+ }, {
96
+ title: 'commonjs - for legacy setups (Node.js < 20)',
97
+ value: 'commonjs',
98
+ selected: true
99
+ }, {
100
+ title: 'typescript - declaration files for typechecking',
101
+ value: 'typescript',
102
+ selected: /\.tsx?$/.test(entryFile)
103
+ }],
104
+ validate: input => Boolean(input.length)
105
+ }];
106
+ if (entryFile.endsWith('.js') && FLOW_PRGAMA_REGEX.test(await _fsExtra.default.readFile(_path.default.join(root, source, entryFile), 'utf-8'))) {
107
+ questions.push({
108
+ type: 'confirm',
109
+ name: 'flow',
110
+ message: 'Do you want to publish definitions for flow?',
111
+ initial: Object.keys(pkg.devDependencies || {}).includes('flow-bin')
112
+ });
113
+ }
114
+ const {
115
+ output,
116
+ targets,
117
+ flow
118
+ } = await (0, _prompts.default)(questions);
119
+ const target = targets[0] === 'commonjs' || targets[0] === 'module' ? targets[0] : undefined;
120
+ const entries = {
121
+ source: `./${_path.default.join(source, entryFile)}`
122
+ };
123
+ let esm = false;
124
+ if (targets.includes('module')) {
125
+ esm = true;
126
+ entries.module = `./${_path.default.join(output, 'module', 'index.js')}`;
127
+ }
128
+ if (targets.includes('commonjs')) {
129
+ entries.commonjs = `./${_path.default.join(output, 'commonjs', 'index.js')}`;
130
+ }
131
+ const types = {};
132
+ if (targets.includes('typescript')) {
133
+ if (targets.includes('commonjs') && targets.includes('module')) {
134
+ types.require = `./${_path.default.join(output, 'typescript', 'commonjs', source, 'index.d.ts')}`;
135
+ types.import = `./${_path.default.join(output, 'typescript', 'module', source, 'index.d.ts')}`;
136
+ } else {
137
+ types.require = `./${_path.default.join(output, 'typescript', source, 'index.d.ts')}`;
138
+ types.import = types.require;
139
+ }
140
+ if (!(await _fsExtra.default.pathExists(_path.default.join(root, 'tsconfig.json')))) {
141
+ const {
142
+ tsconfig
143
+ } = await (0, _prompts.default)({
144
+ type: 'confirm',
145
+ name: 'tsconfig',
146
+ message: `You have enabled 'typescript' compilation, but we couldn't find a 'tsconfig.json' in project root.\n Generate one?`,
147
+ initial: true
148
+ });
149
+ if (tsconfig) {
150
+ await _fsExtra.default.writeJSON(_path.default.join(root, 'tsconfig.json'), {
151
+ compilerOptions: {
152
+ rootDir: '.',
153
+ allowUnreachableCode: false,
154
+ allowUnusedLabels: false,
155
+ esModuleInterop: true,
156
+ forceConsistentCasingInFileNames: true,
157
+ jsx: 'react-jsx',
158
+ lib: ['ESNext'],
159
+ module: 'ESNext',
160
+ moduleResolution: 'bundler',
161
+ noFallthroughCasesInSwitch: true,
162
+ noImplicitReturns: true,
163
+ noImplicitUseStrict: false,
164
+ noStrictGenericChecks: false,
165
+ noUncheckedIndexedAccess: true,
166
+ noUnusedLocals: true,
167
+ noUnusedParameters: true,
168
+ resolveJsonModule: true,
169
+ skipLibCheck: true,
170
+ strict: true,
171
+ target: 'ESNext',
172
+ verbatimModuleSyntax: true
173
+ }
174
+ }, {
175
+ spaces: 2
176
+ });
177
+ }
178
+ }
179
+ }
180
+ const prepare = 'bob build';
181
+ const files = [source, output, '!**/__tests__', '!**/__fixtures__', '!**/__mocks__'];
182
+ if (esm) {
183
+ let replace = false;
184
+ const exportsField = {
185
+ '.': {}
186
+ };
187
+ const importField = {
188
+ ...(types.import ? {
189
+ types: types.import
190
+ } : null),
191
+ ...(entries.module ? {
192
+ default: entries.module
193
+ } : null)
194
+ };
195
+ const requireField = {
196
+ ...(types.require ? {
197
+ types: types.require
198
+ } : null),
199
+ ...(entries.commonjs ? {
200
+ default: entries.commonjs
201
+ } : null)
202
+ };
203
+ if (targets.includes('commonjs') && targets.includes('module')) {
204
+ exportsField['.'] = {
205
+ import: importField,
206
+ require: requireField
207
+ };
208
+ } else if (targets.includes('commonjs')) {
209
+ exportsField['.'] = requireField;
210
+ } else if (targets.includes('module')) {
211
+ exportsField['.'] = importField;
212
+ }
213
+ if (pkg.codegenConfig && !pkg.codegenConfig.includesGeneratedCode) {
214
+ // @ts-expect-error The exports is not strictly types therefore it doesn't know about the package.json property
215
+ exportsField['./package.json'] = './package.json';
216
+ }
217
+ if (pkg.exports && JSON.stringify(pkg.exports) !== JSON.stringify(exportsField)) {
218
+ replace = (await (0, _prompts.default)({
219
+ type: 'confirm',
220
+ name: 'replace',
221
+ message: `Your package.json has 'exports' field set.\n Do you want to replace it?`,
222
+ initial: true
223
+ })).replace;
224
+ } else {
225
+ replace = true;
226
+ }
227
+ if (replace) {
228
+ pkg.exports = exportsField;
229
+ }
230
+ }
231
+ const entryFields = {
232
+ source: entries.source
233
+ };
234
+ if (targets.includes('commonjs') && targets.includes('module')) {
235
+ entryFields.main = entries.commonjs;
236
+ entryFields.module = entries.module;
237
+ } else if (targets.includes('commonjs')) {
238
+ entryFields.main = entries.commonjs;
239
+ } else if (targets.includes('module')) {
240
+ entryFields.main = entries.module;
241
+ }
242
+ if (targets.includes('typescript') && !pkg.exports?.['.']) {
243
+ if (entryFields.main === entries.commonjs) {
244
+ entryFields.types = types.require;
245
+ } else {
246
+ entryFields.types = types.import;
247
+ }
248
+ }
249
+ for (const key in entryFields) {
250
+ const entry = entryFields[key];
251
+ if (pkg[key] && pkg[key] !== entry) {
252
+ const {
253
+ replace
254
+ } = await (0, _prompts.default)({
255
+ type: 'confirm',
256
+ name: 'replace',
257
+ message: `Your package.json has the '${key}' field set to '${pkg[key]}'.\n Do you want to replace it with '${entry}'?`,
258
+ initial: true
259
+ });
260
+ if (replace) {
261
+ pkg[key] = entry;
262
+ }
263
+ } else {
264
+ pkg[key] = entry;
265
+ }
266
+ }
267
+ if (pkg['react-native'] && (pkg['react-native'].startsWith(source) || pkg['react-native'].startsWith(`./${source}`))) {
268
+ const {
269
+ remove
270
+ } = await (0, _prompts.default)({
271
+ type: 'confirm',
272
+ name: 'remove',
273
+ message: `Your package.json has the 'react-native' field pointing to source code.\n This can cause problems when customizing babel configuration.\n Do you want to remove it?`,
274
+ initial: true
275
+ });
276
+ if (remove) {
277
+ delete pkg['react-native'];
278
+ }
279
+ }
280
+ if (pkg.scripts?.prepare && pkg.scripts.prepare !== prepare) {
281
+ const {
282
+ replace
283
+ } = await (0, _prompts.default)({
284
+ type: 'confirm',
285
+ name: 'replace',
286
+ message: `Your package.json has the 'scripts.prepare' field set to '${pkg.scripts.prepare}'.\n Do you want to replace it with '${prepare}'?`,
287
+ initial: true
288
+ });
289
+ if (replace) {
290
+ pkg.scripts.prepare = prepare;
291
+ }
292
+ } else {
293
+ pkg.scripts = pkg.scripts || {};
294
+ pkg.scripts.prepare = prepare;
295
+ }
296
+ if (pkg.files) {
297
+ const pkgFiles = pkg.files;
298
+ if (files?.some(file => !pkgFiles.includes(file))) {
299
+ const {
300
+ update
301
+ } = await (0, _prompts.default)({
302
+ type: 'confirm',
303
+ name: 'update',
304
+ message: `Your package.json already has a 'files' field.\n Do you want to update it?`,
305
+ initial: true
306
+ });
307
+ if (update) {
308
+ pkg.files = [...files, ...pkg.files.filter(file => !files.includes(file))];
309
+ }
310
+ }
311
+ } else {
312
+ pkg.files = files;
313
+ }
314
+ pkg[name] = {
315
+ source,
316
+ output,
317
+ targets: targets.map(t => {
318
+ if (t === target && flow) {
319
+ return [t, {
320
+ copyFlow: true
321
+ }];
322
+ }
323
+ if (t === 'commonjs' || t === 'module') {
324
+ return [t, {
325
+ esm
326
+ }];
327
+ }
328
+ return t;
329
+ })
330
+ };
331
+ if (pkg.jest) {
332
+ const entry = `<rootDir>/${output}/`;
333
+ if (pkg.jest.modulePathIgnorePatterns) {
334
+ const {
335
+ modulePathIgnorePatterns
336
+ } = pkg.jest;
337
+ if (!modulePathIgnorePatterns.includes(entry)) {
338
+ modulePathIgnorePatterns.push(entry);
339
+ }
340
+ } else {
341
+ pkg.jest.modulePathIgnorePatterns = [entry];
342
+ }
343
+ }
344
+ pkg.eslintIgnore = pkg.eslintIgnore || ['node_modules/'];
345
+ if (!pkg.eslintIgnore.includes(`${output}/`)) {
346
+ pkg.eslintIgnore.push(`${output}/`);
347
+ }
348
+ await _fsExtra.default.writeJSON(projectPackagePath, pkg, {
349
+ spaces: 2
350
+ });
351
+ const ignorefiles = [_path.default.join(root, '.gitignore'), _path.default.join(root, '.eslintignore')];
352
+ for (const ignorefile of ignorefiles) {
353
+ if (await _fsExtra.default.pathExists(ignorefile)) {
354
+ const content = await _fsExtra.default.readFile(ignorefile, 'utf-8');
355
+ if (!content.split('\n').includes(`${output}/`)) {
356
+ await _fsExtra.default.writeFile(ignorefile, `${content}\n# generated by bob\n${output}/\n`);
357
+ }
358
+ }
359
+ }
360
+ const packageManager = (await _fsExtra.default.pathExists(_path.default.join(root, 'yarn.lock'))) ? 'yarn' : 'npm';
361
+ process.stdout.write((0, _dedent.default)(`
362
+ Project ${_kleur.default.yellow(pkg.name)} configured successfully!
363
+
364
+ ${_kleur.default.magenta(`${_kleur.default.bold('Perform last steps')} by running`)}${_kleur.default.gray(':')}
365
+
366
+ ${_kleur.default.gray('$')} ${packageManager} install
367
+
368
+ ${_kleur.default.yellow('Good luck!')}
369
+ `));
370
+ }
371
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","names":["_path","_interopRequireDefault","require","_fsExtra","_kleur","_dedent","_isGitDirty","_prompts","logger","_interopRequireWildcard","_loadConfig","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","name","version","FLOW_PRGAMA_REGEX","init","root","process","cwd","projectPackagePath","path","resolve","isGitDirty","shouldContinue","prompts","type","message","initial","exit","fs","pathExists","error","pkg","JSON","parse","readFile","result","loadConfig","config","devDependencies","source","validate","input","Boolean","entryFile","join","fromEntries","entries","sort","b","localeCompare","questions","choices","title","value","selected","test","length","endsWith","push","keys","includes","output","targets","flow","target","undefined","esm","module","commonjs","types","import","tsconfig","writeJSON","compilerOptions","rootDir","allowUnreachableCode","allowUnusedLabels","esModuleInterop","forceConsistentCasingInFileNames","jsx","lib","moduleResolution","noFallthroughCasesInSwitch","noImplicitReturns","noImplicitUseStrict","noStrictGenericChecks","noUncheckedIndexedAccess","noUnusedLocals","noUnusedParameters","resolveJsonModule","skipLibCheck","strict","verbatimModuleSyntax","spaces","prepare","files","replace","exportsField","importField","requireField","codegenConfig","includesGeneratedCode","exports","stringify","entryFields","main","key","entry","startsWith","remove","scripts","pkgFiles","some","file","update","filter","map","copyFlow","jest","modulePathIgnorePatterns","eslintIgnore","ignorefiles","ignorefile","content","split","writeFile","packageManager","stdout","write","dedent","kleur","yellow","magenta","bold","gray"],"sources":["../src/init.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport kleur from 'kleur';\nimport dedent from 'dedent';\nimport isGitDirty from 'is-git-dirty';\nimport prompts, { type PromptObject } from './utils/prompts';\nimport * as logger from './utils/logger';\nimport { loadConfig } from './utils/loadConfig';\n\n// eslint-disable-next-line import/no-commonjs, @typescript-eslint/no-var-requires\nconst { name, version } = require('../package.json');\n\nconst FLOW_PRGAMA_REGEX = /\\*?\\s*@(flow)\\b/m;\n\nexport async function init() {\n const root = process.cwd();\n const projectPackagePath = path.resolve(root, 'package.json');\n\n if (isGitDirty()) {\n const { shouldContinue } = await prompts({\n type: 'confirm',\n name: 'shouldContinue',\n message: `The working directory is not clean.\\n You should commit or stash your changes before configuring bob.\\n Continue anyway?`,\n initial: false,\n });\n\n if (!shouldContinue) {\n process.exit(0);\n }\n }\n\n if (!(await fs.pathExists(projectPackagePath))) {\n logger.error(\n `Couldn't find a 'package.json' file in '${root}'.\\n Are you in a project folder?`\n );\n process.exit(1);\n }\n\n const pkg = JSON.parse(await fs.readFile(projectPackagePath, 'utf-8'));\n const result = await loadConfig();\n\n if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {\n const { shouldContinue } = await prompts({\n type: 'confirm',\n name: 'shouldContinue',\n message: `The project seems to be already configured with bob.\\n Do you want to overwrite the existing configuration?`,\n initial: false,\n });\n\n if (!shouldContinue) {\n process.exit(0);\n }\n }\n\n const { source } = await prompts({\n type: 'text',\n name: 'source',\n message: 'Where are your source files?',\n initial: 'src',\n validate: (input) => Boolean(input),\n });\n\n let entryFile;\n\n if (await fs.pathExists(path.join(root, source, 'index.js'))) {\n entryFile = 'index.js';\n } else if (await fs.pathExists(path.join(root, source, 'index.ts'))) {\n entryFile = 'index.ts';\n } else if (await fs.pathExists(path.join(root, source, 'index.tsx'))) {\n entryFile = 'index.tsx';\n }\n\n if (!entryFile) {\n logger.error(\n `Couldn't find a 'index.js'. 'index.ts' or 'index.tsx' file under '${source}'.\\n Please re-run the CLI after creating it.`\n );\n process.exit(1);\n }\n\n pkg.devDependencies = Object.fromEntries(\n [...Object.entries(pkg.devDependencies || {}), [name, `^${version}`]].sort(\n ([a], [b]) => a.localeCompare(b)\n )\n );\n\n const questions: PromptObject[] = [\n {\n type: 'text',\n name: 'output',\n message: 'Where do you want to generate the output files?',\n initial: 'lib',\n validate: (input: string) => Boolean(input),\n },\n {\n type: 'multiselect',\n name: 'targets',\n message: 'Which targets do you want to build?',\n choices: [\n {\n title: 'module - for modern setups',\n value: 'module',\n selected: true,\n },\n {\n title: 'commonjs - for legacy setups (Node.js < 20)',\n value: 'commonjs',\n selected: true,\n },\n {\n title: 'typescript - declaration files for typechecking',\n value: 'typescript',\n selected: /\\.tsx?$/.test(entryFile),\n },\n ],\n validate: (input: string) => Boolean(input.length),\n },\n ];\n\n if (\n entryFile.endsWith('.js') &&\n FLOW_PRGAMA_REGEX.test(\n await fs.readFile(path.join(root, source, entryFile), 'utf-8')\n )\n ) {\n questions.push({\n type: 'confirm',\n name: 'flow',\n message: 'Do you want to publish definitions for flow?',\n initial: Object.keys(pkg.devDependencies || {}).includes('flow-bin'),\n });\n }\n\n const { output, targets, flow } = await prompts(questions);\n\n const target =\n targets[0] === 'commonjs' || targets[0] === 'module'\n ? targets[0]\n : undefined;\n\n const entries: {\n [key in 'source' | 'commonjs' | 'module']?: string;\n } = {\n source: `./${path.join(source, entryFile)}`,\n };\n\n let esm = false;\n\n if (targets.includes('module')) {\n esm = true;\n entries.module = `./${path.join(output, 'module', 'index.js')}`;\n }\n\n if (targets.includes('commonjs')) {\n entries.commonjs = `./${path.join(output, 'commonjs', 'index.js')}`;\n }\n\n const types: {\n [key in 'require' | 'import']?: string;\n } = {};\n\n if (targets.includes('typescript')) {\n if (targets.includes('commonjs') && targets.includes('module')) {\n types.require = `./${path.join(\n output,\n 'typescript',\n 'commonjs',\n source,\n 'index.d.ts'\n )}`;\n\n types.import = `./${path.join(\n output,\n 'typescript',\n 'module',\n source,\n 'index.d.ts'\n )}`;\n } else {\n types.require = `./${path.join(\n output,\n 'typescript',\n source,\n 'index.d.ts'\n )}`;\n\n types.import = types.require;\n }\n\n if (!(await fs.pathExists(path.join(root, 'tsconfig.json')))) {\n const { tsconfig } = await prompts({\n type: 'confirm',\n name: 'tsconfig',\n message: `You have enabled 'typescript' compilation, but we couldn't find a 'tsconfig.json' in project root.\\n Generate one?`,\n initial: true,\n });\n\n if (tsconfig) {\n await fs.writeJSON(\n path.join(root, 'tsconfig.json'),\n {\n compilerOptions: {\n rootDir: '.',\n allowUnreachableCode: false,\n allowUnusedLabels: false,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n lib: ['ESNext'],\n module: 'ESNext',\n moduleResolution: 'bundler',\n noFallthroughCasesInSwitch: true,\n noImplicitReturns: true,\n noImplicitUseStrict: false,\n noStrictGenericChecks: false,\n noUncheckedIndexedAccess: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n strict: true,\n target: 'ESNext',\n verbatimModuleSyntax: true,\n },\n },\n { spaces: 2 }\n );\n }\n }\n }\n\n const prepare = 'bob build';\n const files = [\n source,\n output,\n '!**/__tests__',\n '!**/__fixtures__',\n '!**/__mocks__',\n ];\n\n if (esm) {\n let replace = false;\n\n const exportsField = {\n '.': {},\n };\n\n const importField = {\n ...(types.import ? { types: types.import } : null),\n ...(entries.module ? { default: entries.module } : null),\n };\n\n const requireField = {\n ...(types.require ? { types: types.require } : null),\n ...(entries.commonjs ? { default: entries.commonjs } : null),\n };\n\n if (targets.includes('commonjs') && targets.includes('module')) {\n exportsField['.'] = {\n import: importField,\n require: requireField,\n };\n } else if (targets.includes('commonjs')) {\n exportsField['.'] = requireField;\n } else if (targets.includes('module')) {\n exportsField['.'] = importField;\n }\n\n if (pkg.codegenConfig && !pkg.codegenConfig.includesGeneratedCode) {\n // @ts-expect-error The exports is not strictly types therefore it doesn't know about the package.json property\n exportsField['./package.json'] = './package.json';\n }\n\n if (\n pkg.exports &&\n JSON.stringify(pkg.exports) !== JSON.stringify(exportsField)\n ) {\n replace = (\n await prompts({\n type: 'confirm',\n name: 'replace',\n message: `Your package.json has 'exports' field set.\\n Do you want to replace it?`,\n initial: true,\n })\n ).replace;\n } else {\n replace = true;\n }\n\n if (replace) {\n pkg.exports = exportsField;\n }\n }\n\n const entryFields: {\n [key in 'source' | 'main' | 'module' | 'types']?: string;\n } = {\n source: entries.source,\n };\n\n if (targets.includes('commonjs') && targets.includes('module')) {\n entryFields.main = entries.commonjs;\n entryFields.module = entries.module;\n } else if (targets.includes('commonjs')) {\n entryFields.main = entries.commonjs;\n } else if (targets.includes('module')) {\n entryFields.main = entries.module;\n }\n\n if (targets.includes('typescript') && !pkg.exports?.['.']) {\n if (entryFields.main === entries.commonjs) {\n entryFields.types = types.require;\n } else {\n entryFields.types = types.import;\n }\n }\n\n for (const key in entryFields) {\n const entry = entryFields[key as keyof typeof entryFields];\n\n if (pkg[key] && pkg[key] !== entry) {\n const { replace } = await prompts({\n type: 'confirm',\n name: 'replace',\n message: `Your package.json has the '${key}' field set to '${pkg[key]}'.\\n Do you want to replace it with '${entry}'?`,\n initial: true,\n });\n\n if (replace) {\n pkg[key] = entry;\n }\n } else {\n pkg[key] = entry;\n }\n }\n\n if (\n pkg['react-native'] &&\n (pkg['react-native'].startsWith(source) ||\n pkg['react-native'].startsWith(`./${source}`))\n ) {\n const { remove } = await prompts({\n type: 'confirm',\n name: 'remove',\n message: `Your package.json has the 'react-native' field pointing to source code.\\n This can cause problems when customizing babel configuration.\\n Do you want to remove it?`,\n initial: true,\n });\n\n if (remove) {\n delete pkg['react-native'];\n }\n }\n\n if (pkg.scripts?.prepare && pkg.scripts.prepare !== prepare) {\n const { replace } = await prompts({\n type: 'confirm',\n name: 'replace',\n message: `Your package.json has the 'scripts.prepare' field set to '${pkg.scripts.prepare}'.\\n Do you want to replace it with '${prepare}'?`,\n initial: true,\n });\n\n if (replace) {\n pkg.scripts.prepare = prepare;\n }\n } else {\n pkg.scripts = pkg.scripts || {};\n pkg.scripts.prepare = prepare;\n }\n\n if (pkg.files) {\n const pkgFiles = pkg.files;\n\n if (files?.some((file) => !pkgFiles.includes(file))) {\n const { update } = await prompts({\n type: 'confirm',\n name: 'update',\n message: `Your package.json already has a 'files' field.\\n Do you want to update it?`,\n initial: true,\n });\n\n if (update) {\n pkg.files = [\n ...files,\n ...pkg.files.filter((file: string) => !files.includes(file)),\n ];\n }\n }\n } else {\n pkg.files = files;\n }\n\n pkg[name] = {\n source,\n output,\n targets: targets.map((t: string) => {\n if (t === target && flow) {\n return [t, { copyFlow: true }];\n }\n\n if (t === 'commonjs' || t === 'module') {\n return [t, { esm }];\n }\n\n return t;\n }),\n };\n\n if (pkg.jest) {\n const entry = `<rootDir>/${output}/`;\n\n if (pkg.jest.modulePathIgnorePatterns) {\n const { modulePathIgnorePatterns } = pkg.jest;\n\n if (!modulePathIgnorePatterns.includes(entry)) {\n modulePathIgnorePatterns.push(entry);\n }\n } else {\n pkg.jest.modulePathIgnorePatterns = [entry];\n }\n }\n\n pkg.eslintIgnore = pkg.eslintIgnore || ['node_modules/'];\n\n if (!pkg.eslintIgnore.includes(`${output}/`)) {\n pkg.eslintIgnore.push(`${output}/`);\n }\n\n await fs.writeJSON(projectPackagePath, pkg, {\n spaces: 2,\n });\n\n const ignorefiles = [\n path.join(root, '.gitignore'),\n path.join(root, '.eslintignore'),\n ];\n\n for (const ignorefile of ignorefiles) {\n if (await fs.pathExists(ignorefile)) {\n const content = await fs.readFile(ignorefile, 'utf-8');\n\n if (!content.split('\\n').includes(`${output}/`)) {\n await fs.writeFile(\n ignorefile,\n `${content}\\n# generated by bob\\n${output}/\\n`\n );\n }\n }\n }\n\n const packageManager = (await fs.pathExists(path.join(root, 'yarn.lock')))\n ? 'yarn'\n : 'npm';\n\n process.stdout.write(\n dedent(`\n Project ${kleur.yellow(pkg.name)} configured successfully!\n\n ${kleur.magenta(\n `${kleur.bold('Perform last steps')} by running`\n )}${kleur.gray(':')}\n\n ${kleur.gray('$')} ${packageManager} install\n\n ${kleur.yellow('Good luck!')}\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,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,MAAA,GAAAC,uBAAA,CAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAAgD,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAA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G,MAAM/F,gBAAE,CAACM,QAAQ,CAACwF,UAAU,EAAE,OAAO,CAAC;MAEtD,IAAI,CAACC,OAAO,CAACC,KAAK,CAAC,IAAI,CAAC,CAAChE,QAAQ,CAAC,GAAGC,MAAM,GAAG,CAAC,EAAE;QAC/C,MAAMjC,gBAAE,CAACiG,SAAS,CAChBH,UAAU,EACV,GAAGC,OAAO,yBAAyB9D,MAAM,KAC3C,CAAC;MACH;IACF;EACF;EAEA,MAAMiE,cAAc,GAAG,CAAC,MAAMlG,gBAAE,CAACC,UAAU,CAACV,aAAI,CAACyB,IAAI,CAAC7B,IAAI,EAAE,WAAW,CAAC,CAAC,IACrE,MAAM,GACN,KAAK;EAETC,OAAO,CAAC+G,MAAM,CAACC,KAAK,CAClB,IAAAC,eAAM,EAAC;AACX,cAAcC,cAAK,CAACC,MAAM,CAACpG,GAAG,CAACpB,IAAI,CAAC;AACpC;AACA,MAAMuH,cAAK,CAACE,OAAO,CACb,GAAGF,cAAK,CAACG,IAAI,CAAC,oBAAoB,CAAC,aACrC,CAAC,GAAGH,cAAK,CAACI,IAAI,CAAC,GAAG,CAAC;AACvB;AACA,QAAQJ,cAAK,CAACI,IAAI,CAAC,GAAG,CAAC,IAAIR,cAAc;AACzC;AACA,MAAMI,cAAK,CAACC,MAAM,CAAC,YAAY,CAAC;AAChC,GAAG,CACD,CAAC;AACH","ignoreList":[]}
@@ -15,12 +15,14 @@ async function build({
15
15
  output,
16
16
  exclude,
17
17
  options,
18
+ variants,
18
19
  report
19
20
  }) {
20
21
  report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
21
22
  await (0, _del.default)([output]);
22
23
  await (0, _compile.default)({
23
24
  ...options,
25
+ variants,
24
26
  root,
25
27
  source,
26
28
  output,
@@ -1 +1 @@
1
- {"version":3,"file":"commonjs.js","names":["_path","_interopRequireDefault","require","_kleur","_del","_compile","e","__esModule","default","build","root","source","output","exclude","options","report","info","kleur","blue","path","relative","del","compile","modules"],"sources":["../../src/targets/commonjs.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile from '../utils/compile';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n options?: {\n esm?: boolean;\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n };\n exclude: string;\n};\n\nexport default async function build({\n root,\n source,\n output,\n exclude,\n options,\n report,\n}: Options) {\n report.info(\n `Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`\n );\n\n await del([output]);\n\n await compile({\n ...options,\n root,\n source,\n output,\n exclude,\n modules: 'commonjs',\n report,\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAcxB,eAAeG,KAAKA,CAAC;EAClCC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC;AACO,CAAC,EAAE;EACVA,MAAM,CAACC,IAAI,CACT,iCAAiCC,cAAK,CAACC,IAAI,CAACC,aAAI,CAACC,QAAQ,CAACV,IAAI,EAAEE,MAAM,CAAC,CAAC,EAC1E,CAAC;EAED,MAAM,IAAAS,YAAG,EAAC,CAACT,MAAM,CAAC,CAAC;EAEnB,MAAM,IAAAU,gBAAO,EAAC;IACZ,GAAGR,OAAO;IACVJ,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPU,OAAO,EAAE,UAAU;IACnBR;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"commonjs.js","names":["_path","_interopRequireDefault","require","_kleur","_del","_compile","e","__esModule","default","build","root","source","output","exclude","options","variants","report","info","kleur","blue","path","relative","del","compile","modules"],"sources":["../../src/targets/commonjs.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile, { type CompileOptions } from '../utils/compile';\nimport type { Input, Variants } from '../types';\n\ntype Options = Input & {\n options?: CompileOptions;\n variants: Variants;\n exclude: string;\n};\n\nexport default async function build({\n root,\n source,\n output,\n exclude,\n options,\n variants,\n report,\n}: Options) {\n report.info(\n `Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`\n );\n\n await del([output]);\n\n await compile({\n ...options,\n variants,\n root,\n source,\n output,\n exclude,\n modules: 'commonjs',\n report,\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASjD,eAAeG,KAAKA,CAAC;EAClCC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC;AACO,CAAC,EAAE;EACVA,MAAM,CAACC,IAAI,CACT,iCAAiCC,cAAK,CAACC,IAAI,CAACC,aAAI,CAACC,QAAQ,CAACX,IAAI,EAAEE,MAAM,CAAC,CAAC,EAC1E,CAAC;EAED,MAAM,IAAAU,YAAG,EAAC,CAACV,MAAM,CAAC,CAAC;EAEnB,MAAM,IAAAW,gBAAO,EAAC;IACZ,GAAGT,OAAO;IACVC,QAAQ;IACRL,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPW,OAAO,EAAE,UAAU;IACnBR;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -15,12 +15,14 @@ async function build({
15
15
  output,
16
16
  exclude,
17
17
  options,
18
+ variants,
18
19
  report
19
20
  }) {
20
21
  report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
21
22
  await (0, _del.default)([output]);
22
23
  await (0, _compile.default)({
23
24
  ...options,
25
+ variants,
24
26
  root,
25
27
  source,
26
28
  output,
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","names":["_path","_interopRequireDefault","require","_kleur","_del","_compile","e","__esModule","default","build","root","source","output","exclude","options","report","info","kleur","blue","path","relative","del","compile","modules"],"sources":["../../src/targets/module.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile from '../utils/compile';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n options?: {\n esm?: boolean;\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n };\n exclude: string;\n};\n\nexport default async function build({\n root,\n source,\n output,\n exclude,\n options,\n report,\n}: Options) {\n report.info(\n `Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`\n );\n\n await del([output]);\n\n await compile({\n ...options,\n root,\n source,\n output,\n exclude,\n modules: 'preserve',\n report,\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAcxB,eAAeG,KAAKA,CAAC;EAClCC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC;AACO,CAAC,EAAE;EACVA,MAAM,CAACC,IAAI,CACT,iCAAiCC,cAAK,CAACC,IAAI,CAACC,aAAI,CAACC,QAAQ,CAACV,IAAI,EAAEE,MAAM,CAAC,CAAC,EAC1E,CAAC;EAED,MAAM,IAAAS,YAAG,EAAC,CAACT,MAAM,CAAC,CAAC;EAEnB,MAAM,IAAAU,gBAAO,EAAC;IACZ,GAAGR,OAAO;IACVJ,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPU,OAAO,EAAE,UAAU;IACnBR;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"module.js","names":["_path","_interopRequireDefault","require","_kleur","_del","_compile","e","__esModule","default","build","root","source","output","exclude","options","variants","report","info","kleur","blue","path","relative","del","compile","modules"],"sources":["../../src/targets/module.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile, { type CompileOptions } from '../utils/compile';\nimport type { Input, Variants } from '../types';\n\ntype Options = Input & {\n options?: CompileOptions;\n variants: Variants;\n exclude: string;\n};\n\nexport default async function build({\n root,\n source,\n output,\n exclude,\n options,\n variants,\n report,\n}: Options) {\n report.info(\n `Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`\n );\n\n await del([output]);\n\n await compile({\n ...options,\n variants,\n root,\n source,\n output,\n exclude,\n modules: 'preserve',\n report,\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASjD,eAAeG,KAAKA,CAAC;EAClCC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC;AACO,CAAC,EAAE;EACVA,MAAM,CAACC,IAAI,CACT,iCAAiCC,cAAK,CAACC,IAAI,CAACC,aAAI,CAACC,QAAQ,CAACX,IAAI,EAAEE,MAAM,CAAC,CAAC,EAC1E,CAAC;EAED,MAAM,IAAAU,YAAG,EAAC,CAACV,MAAM,CAAC,CAAC;EAEnB,MAAM,IAAAW,gBAAO,EAAC;IACZ,GAAGT,OAAO;IACVC,QAAQ;IACRL,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPW,OAAO,EAAE,UAAU;IACnBR;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -18,7 +18,9 @@ async function build({
18
18
  root,
19
19
  output,
20
20
  report,
21
- options
21
+ options,
22
+ variants,
23
+ esm
22
24
  }) {
23
25
  report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
24
26
  await (0, _del.default)([output]);
@@ -83,34 +85,51 @@ async function build({
83
85
  if (tsc == null || !(await _fsExtra.default.pathExists(tsc))) {
84
86
  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.`);
85
87
  }
86
- const outputs = options?.esm ? {
87
- commonjs: _path.default.join(output, 'commonjs'),
88
- module: _path.default.join(output, 'module')
89
- } : {
90
- commonjs: output
91
- };
92
- const tsbuildinfo = _path.default.join(outputs.commonjs, project.replace(/\.json$/, '.tsbuildinfo'));
88
+ const outputs = {};
89
+ if (esm && variants.commonjs && variants.module) {
90
+ outputs.commonjs = _path.default.join(output, 'commonjs');
91
+ outputs.module = _path.default.join(output, 'module');
92
+ } else if (variants.commonjs) {
93
+ outputs.commonjs = output;
94
+ } else {
95
+ outputs.module = output;
96
+ }
97
+ const outDir = outputs.commonjs ?? outputs.module;
98
+ if (outDir == null) {
99
+ throw new Error('Neither commonjs nor module output is enabled.');
100
+ }
101
+ const tsbuildinfo = _path.default.join(outDir, project.replace(/\.json$/, '.tsbuildinfo'));
93
102
  try {
94
103
  await (0, _del.default)([tsbuildinfo]);
95
104
  } catch (e) {
96
105
  // Ignore
97
106
  }
98
- const result = _crossSpawn.default.sync(tsc, ['--pretty', '--declaration', '--declarationMap', '--noEmit', 'false', '--emitDeclarationOnly', '--project', project, '--outDir', outputs.commonjs], {
107
+ const result = _crossSpawn.default.sync(tsc, ['--pretty', '--declaration', '--declarationMap', '--noEmit', 'false', '--emitDeclarationOnly', '--project', project, '--outDir', outDir], {
99
108
  stdio: 'inherit',
100
109
  cwd: root
101
110
  });
102
111
  if (result.status === 0) {
103
112
  await (0, _del.default)([tsbuildinfo]);
104
- if (outputs?.module) {
105
- // When ESM compatible output is enabled, we need to generate 2 builds for commonjs and esm
106
- // In this case we copy the already generated types, and add `package.json` with `type` field
107
- await _fsExtra.default.copy(outputs.commonjs, outputs.module);
108
- await _fsExtra.default.writeJSON(_path.default.join(outputs.commonjs, 'package.json'), {
109
- type: 'commonjs'
110
- });
111
- await _fsExtra.default.writeJSON(_path.default.join(outputs.module, 'package.json'), {
112
- type: 'module'
113
- });
113
+ if (esm) {
114
+ if (outputs?.commonjs && outputs?.module) {
115
+ // When ESM compatible output is enabled and commonjs build is present, we need to generate 2 builds for commonjs and esm
116
+ // In this case we copy the already generated types, and add `package.json` with `type` field
117
+ await _fsExtra.default.copy(outputs.commonjs, outputs.module);
118
+ await _fsExtra.default.writeJSON(_path.default.join(outputs.commonjs, 'package.json'), {
119
+ type: 'commonjs'
120
+ });
121
+ await _fsExtra.default.writeJSON(_path.default.join(outputs.module, 'package.json'), {
122
+ type: 'module'
123
+ });
124
+ } else if (outputs?.commonjs) {
125
+ await _fsExtra.default.writeJSON(_path.default.join(outputs.commonjs, 'package.json'), {
126
+ type: 'commonjs'
127
+ });
128
+ } else if (outputs?.module) {
129
+ await _fsExtra.default.writeJSON(_path.default.join(outputs.module, 'package.json'), {
130
+ type: 'module'
131
+ });
132
+ }
114
133
  }
115
134
  report.success(`Wrote definition files to ${_kleur.default.blue(_path.default.relative(root, output))}`);
116
135
  const pkg = JSON.parse(await _fsExtra.default.readFile(_path.default.join(root, 'package.json'), 'utf-8'));
@@ -118,22 +137,26 @@ async function build({
118
137
  name: 'types',
119
138
  value: pkg.types,
120
139
  output: outputs.commonjs,
121
- error: false
140
+ error: false,
141
+ message: undefined
122
142
  }, ...(pkg.exports?.['.']?.types ? [{
123
143
  name: "exports['.'].types",
124
144
  value: pkg.exports?.['.']?.types,
125
- output: outputs.commonjs,
126
- error: options?.esm === true
145
+ output: outDir,
146
+ error: Boolean(esm && variants.commonjs && variants.module),
147
+ message: `using both ${_kleur.default.blue('commonjs')} and ${_kleur.default.blue('module')} targets with ${_kleur.default.blue('esm')} option enabled. Specify ${_kleur.default.blue("exports['.'].import.types")} and ${_kleur.default.blue("exports['.'].require.types")} instead.`
127
148
  }] : []), {
128
149
  name: "exports['.'].import.types",
129
150
  value: pkg.exports?.['.']?.import?.types,
130
151
  output: outputs.module,
131
- error: !options?.esm
152
+ error: !esm,
153
+ message: `the ${_kleur.default.blue('esm')} option is not enabled for the ${_kleur.default.blue('module')} target`
132
154
  }, {
133
155
  name: "exports['.'].require.types",
134
156
  value: pkg.exports?.['.']?.require?.types,
135
157
  output: outputs.commonjs,
136
- error: !options?.esm
158
+ error: false,
159
+ message: undefined
137
160
  }];
138
161
  const getGeneratedTypesPath = async field => {
139
162
  if (!field.output || field.error) {
@@ -153,7 +176,7 @@ async function build({
153
176
  const invalidFieldNames = (await Promise.all(fields.map(async field => {
154
177
  if (field.error) {
155
178
  if (field.value) {
156
- report.warn(`The ${_kleur.default.blue(field.name)} field in ${_kleur.default.blue(`package.json`)} should not be set when the ${_kleur.default.blue('esm')} option is ${options?.esm ? 'enabled' : 'disabled'}.`);
179
+ report.warn(`The ${_kleur.default.blue(field.name)} field in ${_kleur.default.blue(`package.json`)} should not be set when ${field.message}.`);
157
180
  }
158
181
  return null;
159
182
  }