Skip to content

Commit

Permalink
fix: support cjs files in apps equivalent to js files
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Mar 1, 2021
1 parent 9c167fb commit 4b2c8fc
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,8 @@ AndroidBuilder.prototype.generateRequireIndex = async function generateRequireIn
await walkDir(filePath);
} else if (stat.isFile()) {
const lowerCaseFileName = fileName.toLowerCase();
if (lowerCaseFileName.endsWith('.js') || lowerCaseFileName.endsWith('.json')) {
// TODO: Support mjs files!
if (lowerCaseFileName.endsWith('.js') || lowerCaseFileName.endsWith('.json') || lowerCaseFileName.endsWith('.cjs')) {
let normalizedFilePath = filePath.replace(/\\/g, '/');
normalizedFilePath = normalizedFilePath.replace(normalizedAssetsDir + '/', '');
filePathDictionary[normalizedFilePath] = 1;
Expand Down
2 changes: 1 addition & 1 deletion build/scons-xcode-project-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function generateIndexJSON(dirToTraverse) {
if (fs.existsSync(file)) {
if (fs.statSync(file).isDirectory()) {
walk(file);
} else if (/\.js(on)?$/.test(filename)) {
} else if (/\.(c?js|json)$/.test(filename)) { // TODO: Support mjs files!
index[file.replace(/\\/g, '/').replace(dirToTraverse + '/', 'Resources/')] = 1;
}
}
Expand Down
2 changes: 2 additions & 0 deletions cli/lib/gather.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ class Categorizer {
_handleFile(results, relPath, info) {
switch (info.ext) {
case 'js':
case 'cjs':
// case 'mjs': // FIXME: Support mjs!
results.jsFiles.set(relPath, info);
break;

Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/FilesystemModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ - (JSValue *)getFile

- (TiFile *)getFileProxy:(NSString *)path
{
if ([path hasSuffix:@".js"] || [path hasSuffix:@".json"]) {
if ([path hasSuffix:@".js"] || [path hasSuffix:@".json"] || [path hasSuffix:@".cjs"]) { // FIXME: Handle mjs?
NSString *resourcesDir = [self resourcesDirectory];
if ([path hasPrefix:resourcesDir] || [path hasPrefix:[resourcesDir stringByStandardizingPath]]) {
NSURL *url = [NSURL fileURLWithPath:path];
Expand Down
2 changes: 1 addition & 1 deletion iphone/TitaniumKit/TitaniumKit/Sources/API/Bridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (NSString *)basename
basename = [@"app" retain];
} else {
NSString *last = [[url path] lastPathComponent];
basename = [[last stringByReplacingOccurrencesOfString:@".js" withString:@""] retain];
basename = [[last stringByReplacingOccurrencesOfString:@".js" withString:@""] retain]; // FIXME: Handle cjs/mjs?
}
}
return basename;
Expand Down
2 changes: 1 addition & 1 deletion iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6546,7 +6546,7 @@ iOSBuilder.prototype.generateRequireIndex = async function generateRequireIndex(
if (fs.existsSync(file)) {
if (fs.statSync(file).isDirectory()) {
walk(file);
} else if (/\.js(on)?$/.test(filename)) {
} else if (/\.(c?js|json)$/.test(filename)) { // TODO: Support mjs files!
const modifiedFilename = file.replace(/\\/g, '/').replace(binAssetsDir + '/', 'Resources/');
index[modifiedFilename] = 1; // 1 for exists on disk
}
Expand Down

0 comments on commit 4b2c8fc

Please sign in to comment.