You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add ENVIRONMENT to specify which environment the code will run in (#6565)
By default we still emit code that can run in node, web, shell, etc., but with the option the user can fix only one to be emitted.
This also sets ENVIRONMENT to "web" if the user specifies an HTML output (emcc [..] -o code.html). In that case the indication is clear that the code should only run on the web. This is technically a breaking change though, as people may have tried to run the .js file outside of the web, and that may have worked in some cases. To prevent confusion, when ASSERTIONS are on we show an error if we hit a problem, and also in debug logging we mention doing HTML output setting the environment that way. The benefit to doing this is that it gets all the benefits of web-only emitting in a natural way for the main use case.
For more details on the benefits, see #6542#1140, but basically
* When targeting only web, we don't emit node.js support code which includes require() operations that confuse bundlers.
* We emit less unneeded code.
// Unreachable because SHELL is dependent on the others
262
-
thrownewError('unknown runtime environment');
263
-
}
276
+
thrownewError('not compiled with support for this runtime environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
264
277
#endif // ASSERTIONS
278
+
}
265
279
266
280
// console.log is checked first, as 'print' on the web will open a print dialogue
267
281
// printErr is preferable to console.warn (works better in shells)
0 commit comments