Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transpiling and minifying TypeError: api.caller is not a function #38

Closed
iokill opened this issue Jan 11, 2024 · 2 comments
Closed

Transpiling and minifying TypeError: api.caller is not a function #38

iokill opened this issue Jan 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@iokill
Copy link

iokill commented Jan 11, 2024

Since updating to meteor-desktop v3.2.0 I'm getting an error when running npm run desktop -- build-installer ...:

INFO  electronApp:  excluding files from packing
INFO  electronApp:  transpiling and uglifying
ERROR  electronApp:  error while transpiling or minifying:  TypeError: api.caller is not a function
    at builder (C:\Users\X\Y\node_modules\@babel\preset-env\src\index.ts:390:13)
    at C:\Users\X\Y\node_modules\@babel\helper-plugin-utils\src\index.ts:62:12
    at ElectronApp.transpileAndMinify (C:\Users\X\Y\node_modules\@meteor-community\meteor-desktop\lib\electronApp.js:854:33)
    at ElectronApp.build (C:\Users\X\Y\node_modules\@meteor-community\meteor-desktop\lib\electronApp.js:451:24)
    at MeteorDesktop.buildInstaller (C:\Users\X\Y\node_modules\@meteor-community\meteor-desktop\lib\index.js:111:9)

It appears that the meteor-desktop-bundler package is affected too as I'm getting a similar error from it.

To Reproduce

Simply running npm run desktop -- build-installer ... is enough for me once I've updated to meteor-desktop v3.2.0.

Expected behavior

No error during installer build.

Versions (please complete the following information):

  • Meteor version: 2.14
  • Package version: 3.2.0

Additional context

I've tried to track this down and it appears that some refactoring of @babel/preset-env seems to have caused this: babel/babel#15988. Also note the comment there why ?. was removed when accessing api.caller, so I believe this is an issue in meteor-desktop rather than preset-env.

A quick and dirty fix for me was to simply provide a dummy caller function in the object passed to preset-env like this:

diff --git a/lib/electronApp.js b/lib/electronApp.js
index eecf05f..fb6f3ca 100644
--- a/lib/electronApp.js
+++ b/lib/electronApp.js
@@ -853,7 +853,8 @@ export default class ElectronApp {

         const preset = presetEnv({
             version: require('../package.json').dependencies['@babel/preset-env'],
-            assertVersion: () => { }
+            assertVersion: () => { },
+            caller: () => false,
         }, { targets: { node: '14' } });

         const { data: files } = await this.$.utils.readDir(this.$.env.paths.desktopTmp.root);

Though this seems to me like a hack as this will break again once present-env changes their API. Isn't there a more stable way for meteor-desktop to call babel with options from preset-env?

Just for reference, here is some issues I've found which might be related:

@iokill iokill added the bug Something isn't working label Jan 11, 2024
Copy link

Thank you for submitting this issue!

We, the Members of Meteor Community Packages take every issue seriously.
Our goal is to provide long-term lifecycles for packages and keep up
with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.

However, we contribute to these packages mostly in our free time.
Therefore, we can't guarantee your issues to be solved within certain time.

If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.

Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know

@iokill
Copy link
Author

iokill commented Jan 24, 2024

Appears to be a dup of #37, so closing this. Sorry, that issue was created while I was creating mine 😅

@iokill iokill closed this as completed Jan 24, 2024
iokill added a commit to innerspacetrainings/meteor-desktop that referenced this issue Jan 24, 2024
Add workaround for present-env usage to fix
Meteor-Community-Packages#38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant