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

Safari support #212

Closed
tali opened this issue Oct 2, 2022 · 3 comments
Closed

Safari support #212

tali opened this issue Oct 2, 2022 · 3 comments

Comments

@tali
Copy link

tali commented Oct 2, 2022

Safari (version 16) does not support TrustedTypes and safevalues thus falls back to its own implementation (HtmlImpl).
But HtmlImpl is only working in nodejs environments as it checks for an environment variable via process.env (see html_impl.ts:20)
When using safevalues in Safari, this only leads to the error message 'ReferenceError: Can't find variable: process'.

@neuracr
Copy link
Collaborator

neuracr commented Oct 3, 2022

Thanks for reporting.
Do you have a link to a reproducer?

The intended behavior depends on the webpack mode (https://webpack.js.org/guides/production/#specify-the-mode):

  • In 'production' mode, the html_impl.ts:20 block should be optimized away, as well as the dev.ts
  • In anything else than 'production', dev.ts sets the process variable when it's not running in Node. The block in html_impl.ts:20 is not optimized away.

I've found https://github.com/pahund/webpack-devprod-experiment which does a similar thing.

@tali
Copy link
Author

tali commented Oct 3, 2022

I found this problem in Gerrit master, which now uses safevalues.
Gerrit uses rollup instead of webpack, but when I use rollup-plugin-define for process.env.NODE_ENV then it works as intended again.
Thanks for the help!

hanwen pushed a commit to GerritCodeReview/gerrit that referenced this issue Oct 5, 2022
The JavaScript package `safevalues` introduced in I7f7ac71c uses the
environment variable `NODE_ENV`.
According to the discussion in google/safevalues#212,
this should be defined when bundling the library.
So use the plugin `rollup-plugin-define` to define `process.env.NODE_ENV`.

Release-Notes: skip
Change-Id: I017336a05af99e4e7517221ab9658df7eb5646ad
@neuracr neuracr closed this as completed Oct 5, 2022
@tali
Copy link
Author

tali commented Oct 10, 2022

Gerrit bug https://bugs.chromium.org/p/gerrit/issues/detail?id=16296 is closed.

@tali tali closed this as completed Oct 10, 2022
hanwen pushed a commit to GerritCodeReview/gerrit that referenced this issue Oct 14, 2022
The JavaScript package `safevalues` introduced in I7f7ac71c uses the
environment variable `NODE_ENV`.
According to the discussion in google/safevalues#212,
this should be defined when bundling the library.
So use the plugin `rollup-plugin-define` to define `process.env.NODE_ENV`.

Release-Notes: skip
Change-Id: I017336a05af99e4e7517221ab9658df7eb5646ad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants