Skip to content

Commit

Permalink
Define JavaScript process.env.NODE_ENV="production"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tali committed Oct 3, 2022
1 parent b63f667 commit c94b94c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
9 changes: 8 additions & 1 deletion polygerrit-ui/app/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function requirePlugin(id) {

const resolve = requirePlugin('rollup-plugin-node-resolve');
const {terser} = requirePlugin('rollup-plugin-terser');
const define = requirePlugin('rollup-plugin-define');

// @polymer/font-roboto-local uses import.meta.url value
// as a base path to fonts. We should substitute a correct javascript
Expand Down Expand Up @@ -75,5 +76,11 @@ export default {
extensions: ['.js'],
moduleDirectory: 'external/ui_npm/node_modules',
},
}), importLocalFontMetaUrlResolver()],
}),
define({
replacements: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
}),
importLocalFontMetaUrlResolver()],
};
3 changes: 3 additions & 0 deletions polygerrit-ui/app/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def polygerrit_bundle(name, srcs, outs, entry_point, app_name):
silent = True,
sourcemap = "hidden",
deps = [
"@tools_npm//rollup-plugin-define",
"@tools_npm//rollup-plugin-node-resolve",
],
)
Expand All @@ -42,6 +43,7 @@ def polygerrit_bundle(name, srcs, outs, entry_point, app_name):
silent = True,
sourcemap = "hidden",
deps = [
"@tools_npm//rollup-plugin-define",
"@tools_npm//rollup-plugin-node-resolve",
],
)
Expand All @@ -55,6 +57,7 @@ def polygerrit_bundle(name, srcs, outs, entry_point, app_name):
silent = True,
sourcemap = "hidden",
deps = [
"@tools_npm//rollup-plugin-define",
"@tools_npm//rollup-plugin-node-resolve",
],
)
Expand Down
1 change: 1 addition & 0 deletions tools/node_tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"polymer-bundler": "^4.0.10",
"rollup": "^2.3.4",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-define": "^1.0.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.1.3",
"typescript": "^4.7.2"
Expand Down
40 changes: 39 additions & 1 deletion tools/node_tools/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==

"@rollup/pluginutils@^4.0.0":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz#e6c6c3aba0744edce3fb2074922d3776c0af2a6d"
integrity sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==
dependencies:
estree-walker "^2.0.1"
picomatch "^2.2.2"

"@sindresorhus/is@^4.0.0":
version "4.6.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f"
Expand Down Expand Up @@ -576,6 +584,11 @@ array-back@^3.0.1, array-back@^3.1.0:
resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0"
integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==

ast-matcher@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ast-matcher/-/ast-matcher-1.1.1.tgz#95a6dc72318319507024fff438b7839e4e280813"
integrity sha512-wQPAp09kPFRQsOijM2Blfg4lH6B9MIhIUrhFtDdhD/1JFhPmfg2/+WAjViVYl3N7EwleHI+q/enTHjaDrv+wEw==

async@^2.0.1:
version "2.6.4"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"
Expand Down Expand Up @@ -985,6 +998,11 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==

escape-string-regexp@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==

espree@^3.5.2:
version "3.5.4"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7"
Expand All @@ -998,6 +1016,11 @@ estree-walker@^0.6.1:
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==

estree-walker@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==

esutils@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
Expand Down Expand Up @@ -1325,7 +1348,7 @@ magic-string@^0.22.4:
dependencies:
vlq "^0.2.2"

magic-string@^0.25.2:
magic-string@^0.25.2, magic-string@^0.25.7:
version "0.25.9"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c"
integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==
Expand Down Expand Up @@ -1458,6 +1481,11 @@ pend@~1.2.0:
resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50"
integrity sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==

picomatch@^2.2.2:
version "2.3.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

plist@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/plist/-/plist-2.1.0.tgz#57ccdb7a0821df21831217a3cad54e3e146a1025"
Expand Down Expand Up @@ -1652,6 +1680,16 @@ rollup-plugin-commonjs@^10.1.0:
resolve "^1.11.0"
rollup-pluginutils "^2.8.1"

rollup-plugin-define@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-define/-/rollup-plugin-define-1.0.1.tgz#45b027cec9d2e30df71118efa156170e3846fd3d"
integrity sha512-SM/CKFpLvWq5xBEf84ff/ooT3KodXPVITCkRliyNccuq8SZMpzthN/Bp7JkWScbGTX5lo1SF3cjxKKDjnnFCuA==
dependencies:
"@rollup/pluginutils" "^4.0.0"
ast-matcher "^1.1.1"
escape-string-regexp "^4.0.0"
magic-string "^0.25.7"

rollup-plugin-node-resolve@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz#730f93d10ed202473b1fb54a5997a7db8c6d8523"
Expand Down

0 comments on commit c94b94c

Please sign in to comment.