1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.getBareExtensions = getBareExtensions; 7exports.getExtensions = getExtensions; 8exports.getLanguageExtensionsInOrder = getLanguageExtensionsInOrder; 9function _assert() { 10 const data = _interopRequireDefault(require("assert")); 11 _assert = function () { 12 return data; 13 }; 14 return data; 15} 16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 17function getExtensions(platforms, extensions, workflows) { 18 // In the past we used spread operators to collect the values so now we enforce type safety on them. 19 (0, _assert().default)(Array.isArray(platforms), 'Expected: `platforms: string[]`'); 20 (0, _assert().default)(Array.isArray(extensions), 'Expected: `extensions: string[]`'); 21 (0, _assert().default)(Array.isArray(workflows), 'Expected: `workflows: string[]`'); 22 const fileExtensions = []; 23 // support .expo files 24 for (const workflow of [...workflows, '']) { 25 // Ensure order is correct: [platformA.js, platformB.js, js] 26 for (const platform of [...platforms, '']) { 27 // Support both TypeScript and JavaScript 28 for (const extension of extensions) { 29 fileExtensions.push([platform, workflow, extension].filter(Boolean).join('.')); 30 } 31 } 32 } 33 return fileExtensions; 34} 35function getLanguageExtensionsInOrder({ 36 isTS, 37 isModern, 38 isReact 39}) { 40 // @ts-ignore: filter removes false type 41 const addLanguage = lang => [lang, isReact && `${lang}x`].filter(Boolean); 42 43 // Support JavaScript 44 let extensions = addLanguage('js'); 45 if (isModern) { 46 extensions.unshift('mjs'); 47 } 48 if (isTS) { 49 extensions = [...addLanguage('ts'), ...extensions]; 50 } 51 return extensions; 52} 53function getBareExtensions(platforms, languageOptions = { 54 isTS: true, 55 isModern: true, 56 isReact: true 57}) { 58 const fileExtensions = getExtensions(platforms, getLanguageExtensionsInOrder(languageOptions), []); 59 // Always add these last 60 _addMiscellaneousExtensions(platforms, fileExtensions); 61 return fileExtensions; 62} 63function _addMiscellaneousExtensions(platforms, fileExtensions) { 64 // Always add these with no platform extension 65 // In the future we may want to add platform and workspace extensions to json. 66 fileExtensions.push('json'); 67 // Native doesn't currently support web assembly. 68 if (platforms.includes('web')) { 69 fileExtensions.push('wasm'); 70 } 71 return fileExtensions; 72} 73//# sourceMappingURL=extensions.js.map