Skip to content

Commit 4b2c8fc

Browse files
committed
fix: support cjs files in apps equivalent to js files
1 parent 9c167fb commit 4b2c8fc

File tree

6 files changed

+8
-5
lines changed

6 files changed

+8
-5
lines changed

android/cli/commands/_build.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,8 @@ AndroidBuilder.prototype.generateRequireIndex = async function generateRequireIn
28432843
awaitwalkDir(filePath);
28442844
}elseif(stat.isFile()){
28452845
constlowerCaseFileName=fileName.toLowerCase();
2846-
if(lowerCaseFileName.endsWith('.js')||lowerCaseFileName.endsWith('.json')){
2846+
// TODO: Support mjs files!
2847+
if(lowerCaseFileName.endsWith('.js')||lowerCaseFileName.endsWith('.json')||lowerCaseFileName.endsWith('.cjs')){
28472848
letnormalizedFilePath=filePath.replace(/\\/g,'/');
28482849
normalizedFilePath=normalizedFilePath.replace(normalizedAssetsDir+'/','');
28492850
filePathDictionary[normalizedFilePath]=1;

build/scons-xcode-project-build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function generateIndexJSON(dirToTraverse) {
2929
if(fs.existsSync(file)){
3030
if(fs.statSync(file).isDirectory()){
3131
walk(file);
32-
}elseif(/\.js(on)?$/.test(filename)){
32+
}elseif(/\.(c?js|json)$/.test(filename)){// TODO: Support mjs files!
3333
index[file.replace(/\\/g,'/').replace(dirToTraverse+'/','Resources/')]=1;
3434
}
3535
}

cli/lib/gather.js

+2
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ class Categorizer {
234234
_handleFile(results,relPath,info){
235235
switch(info.ext){
236236
case'js':
237+
case'cjs':
238+
// case 'mjs': // FIXME: Support mjs!
237239
results.jsFiles.set(relPath,info);
238240
break;
239241

iphone/Classes/FilesystemModule.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ - (JSValue *)getFile
192192

193193
- (TiFile *)getFileProxy:(NSString *)path
194194
{
195-
if ([path hasSuffix:@".js"] || [path hasSuffix:@".json"]) {
195+
if ([path hasSuffix:@".js"] || [path hasSuffix:@".json"] || [path hasSuffix:@".cjs"]) {// FIXME: Handle mjs?
196196
NSString *resourcesDir = [selfresourcesDirectory];
197197
if ([path hasPrefix:resourcesDir] || [path hasPrefix:[resourcesDir stringByStandardizingPath]]) {
198198
NSURL *url = [NSURLfileURLWithPath:path];

iphone/TitaniumKit/TitaniumKit/Sources/API/Bridge.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ - (NSString *)basename
4141
basename = [@"app"retain];
4242
} else {
4343
NSString *last = [[url path] lastPathComponent];
44-
basename = [[last stringByReplacingOccurrencesOfString:@".js"withString:@""] retain];
44+
basename = [[last stringByReplacingOccurrencesOfString:@".js"withString:@""] retain];// FIXME: Handle cjs/mjs?
4545
}
4646
}
4747
return basename;

iphone/cli/commands/_build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6546,7 +6546,7 @@ iOSBuilder.prototype.generateRequireIndex = async function generateRequireIndex(
65466546
if(fs.existsSync(file)){
65476547
if(fs.statSync(file).isDirectory()){
65486548
walk(file);
6549-
}elseif(/\.js(on)?$/.test(filename)){
6549+
}elseif(/\.(c?js|json)$/.test(filename)){// TODO: Support mjs files!
65506550
constmodifiedFilename=file.replace(/\\/g,'/').replace(binAssetsDir+'/','Resources/');
65516551
index[modifiedFilename]=1;// 1 for exists on disk
65526552
}

0 commit comments

Comments
 (0)
close