Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
278178f
feat: update Gradle and Android build tools versions to 8.14.3 and 8.…
edusperoni Aug 19, 2025
6b76cad
chore: 9.0.0-alpha.0
NathanWalker Aug 24, 2025
6ab9f01
Merge remote-tracking branch 'origin/main' into feat/allow-conditiona…
NathanWalker Aug 24, 2025
00529a8
feat: es module support
NathanWalker Aug 26, 2025
48d5939
feat: es module support
NathanWalker Aug 26, 2025
fbfb74e
feat: es module support
NathanWalker Aug 27, 2025
2067b0b
feat: sbg support for es modules
NathanWalker Aug 27, 2025
bd24b43
fix: application path to use absolute path instead of relative, more …
NathanWalker Aug 27, 2025
66eff21
feat: handle .js and .mjs extensions when loading main
NathanWalker Aug 27, 2025
25ff64e
chore: es module tests
NathanWalker Aug 27, 2025
74e4097
chore: 9.0.0-alpha.1
NathanWalker Aug 28, 2025
9275d5b
feat: provide node:url polyfill
NathanWalker Aug 28, 2025
1d7e32b
chore: 9.0.0-alpha.2
NathanWalker Aug 28, 2025
bd900f7
feat: use terminal reporter and fix tests
NathanWalker Sep 7, 2025
d25130f
fix: unique filename handling with static binding generator
NathanWalker Sep 7, 2025
e66a428
feat: es module dynamic import support
NathanWalker Sep 7, 2025
ce03b17
feat: logScriptLoading - this may be unnecessary really, added for al…
NathanWalker Sep 7, 2025
ccef166
chore: 9.0.0-alpha.3
NathanWalker Sep 9, 2025
bee756c
Merge remote-tracking branch 'origin/main' into feat/allow-conditiona…
NathanWalker Sep 11, 2025
116a45d
Merge remote-tracking branch 'origin/main' into feat/allow-conditiona…
NathanWalker Oct 23, 2025
2006895
chore: test-app/tools/check_console_test_results.js
NathanWalker Oct 23, 2025
4ce886a
chore: test-app/tools/check_console_test_results.js
NathanWalker Oct 23, 2025
ed5fad9
chore: test-app/tools/check_console_test_results.js
NathanWalker Oct 23, 2025
dd5c2ca
Merge remote-tracking branch 'origin/main' into feat/allow-conditiona…
NathanWalker Nov 5, 2025
7fc7277
chore: cleanup
NathanWalker Nov 5, 2025
282ded6
chore: cleanup
NathanWalker Nov 5, 2025
abaaad8
chore: revert version.h change
NathanWalker Nov 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: sbg support for es modules
  • Loading branch information
NathanWalker committed Aug 27, 2025
commit 2067b0bc283819b29c16769bc2a0f44ed1527afb
30 changes: 25 additions & 5 deletions test-app/build-tools/jsparser/js_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function readInterfaceNames(data, err) {
}

/*
* Traverses a given input directory and attempts to visit every ".js" file.
* Traverses a given input directory and attempts to visit every ".js" and ".mjs" file.
* It passes each found file down the line.
*/
function traverseAndAnalyseFilesDir(inputDir, err) {
Expand All @@ -196,7 +196,7 @@ function traverseAndAnalyseFilesDir(inputDir, err) {
function traverseFiles(filesToTraverse) {
for (let i = 0; i < filesToTraverse.length; i += 1) {
const fp = filesToTraverse[i];
logger.info("Visiting JavaScript file: " + fp);
logger.info("Visiting JavaScript/ES Module file: " + fp);

readFile(fp)
.then(astFromFileContent.bind(null, fp))
Expand Down Expand Up @@ -228,6 +228,7 @@ const readFile = function (filePath, err) {

/*
* Get's the AST (https://en.wikipedia.org/wiki/Abstract_syntax_tree) from the file content and passes it down the line.
* Supports both CommonJS (.js) and ES modules (.mjs) files.
*/
const astFromFileContent = function (path, data, err) {
return new Promise(function (resolve, reject) {
Expand All @@ -236,13 +237,28 @@ const astFromFileContent = function (path, data, err) {
return reject(err);
}

const ast = babelParser.parse(data.data, {
// Determine if this is an ES module based on file extension
const isESModule = path.endsWith('.mjs');

// Configure Babel parser based on file type
const parserOptions = {
minify: false,
plugins: [
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
"objectRestSpread",
],
});
};

// For ES modules, set sourceType to 'module'
if (isESModule) {
parserOptions.sourceType = 'module';
logger.info(`Parsing ES module: ${path}`);
} else {
// For regular JS files, keep existing behavior (default sourceType is 'script')
logger.info(`Parsing CommonJS file: ${path}`);
}

const ast = babelParser.parse(data.data, parserOptions);
data.ast = ast;
return resolve(data);
});
Expand All @@ -266,14 +282,18 @@ const visitAst = function (path, data, err) {

traverse.default(data.ast, {
enter: function (path) {
// Determine file extension length to properly strip it from the path
const fileExtension = data.filePath.endsWith('.mjs') ? '.mjs' : '.js';
const extensionLength = fileExtension.length;

const decoratorConfig = {
logger: logger,
extendDecoratorName: extendDecoratorName,
interfacesDecoratorName: interfacesDecoratorName,
filePath:
data.filePath.substring(
inputDir.length + 1,
data.filePath.length - 3
data.filePath.length - extensionLength
) || "",
fullPathName: data.filePath
.substring(inputDir.length + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,6 @@ private static boolean isWorkerScript(String currFile) {
}

private static boolean isJsFile(String fileName) {
return fileName.substring(fileName.length() - 3).equals(".js");
return fileName.endsWith(".js") || fileName.endsWith(".mjs");
}
}