[Pkg-javascript-devel] Bug#979208: libjs-source-map breaks ruby-terser with err ExecJS::ProgramError: ReferenceError: window is not defined
Pirate Praveen
praveen at onenetbeyond.org
Mon Jan 4 08:18:23 GMT 2021
package: libjs-source-map
version: 0.7.0++dfsg2+really.0.6.1-4
severity: grave
Control: affects -1 ruby-terser
Upstream npmjs.com dist tarball has the following at the top of
dist/source-map.min.js
!function(e,n){"object"==typeof exports&&"object"==typeof
module?module.exports=n():"function"==typeof
define&&define.amd?define([],n):"object"==typeof
exports?exports.sourceMap=n():e.sourceMap=n()}(this,function(){return
function(e){function n(t){if(r[t])return r[t].exports;
But debian package ships with the following ("window,function()"
instead of "this,function()",
!function(e,n){"object"==typeof exports&&"object"==typeof
module?module.exports=n():"function"==typeof
define&&define.amd?define([],n):"object"==typeof
exports?exports.sourceMap=n():e.sourceMap=n()}(window,function(){return
function(e){var n={};function r(t){if(n[t])return n[t].exports;
which breaks no browser environments like ruby execjs/rails assets
pipeline.
This caused gitlab asset precompilation failure, which now switched to
ruby-terser from earlier ruby-uglifier.
rake aborted!
ExecJS::ProgramError: ReferenceError: window is not defined
(execjs):441:200
(execjs):502:14
(execjs):1:40
Object.<anonymous> ((execjs):1:58)
Module._compile (internal/modules/cjs/loader.js:1015:30)
Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
Module.load (internal/modules/cjs/loader.js:879:32)
Function.Module._load (internal/modules/cjs/loader.js:724:14)
Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:60:12)
internal/main/run_main_module.js:17:47
/usr/share/rubygems-integration/all/gems/terser-1.0.2/lib/terser.rb:183:in
`context'
/usr/share/rubygems-integration/all/gems/terser-1.0.2/lib/terser.rb:223:in
`run_terserjs'
/usr/share/rubygems-integration/all/gems/terser-1.0.2/lib/terser.rb:164:in
`compile'
/usr/share/rubygems-integration/all/gems/terser-1.0.2/lib/terser/compressor.rb:45:in
`call'
/usr/share/rubygems-integration/all/gems/terser-1.0.2/lib/terser/compressor.rb:23:in
`call'
/usr/share/rubygems-integration/all/gems/actionview-6.0.3.4/lib/action_view/helpers/asset_url_helper.rb:201:in
`asset_path'
/usr/share/gitlab/app/assets/javascripts/lib/ace/ace_config_paths.js.erb:22:in
`block in _evaluate_template'
/usr/share/gitlab/app/assets/javascripts/lib/ace/ace_config_paths.js.erb:21:in
`each'
/usr/share/gitlab/app/assets/javascripts/lib/ace/ace_config_paths.js.erb:21:in
`_evaluate_template'
/usr/share/rubygems-integration/all/gems/rake-13.0.1/exe/rake:27:in
`<top (required)>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
Upstream build is using webpack 1.12 where as we have webpack 4.43 so
we need to update our webpack configuration.
As per
https://dev.to/riversun/recipes-on-how-to-create-a-library-that-supports-both-browser-and-node-js-201m
we should add globalObject: 'this', to webpack configuration.
More information about the Pkg-javascript-devel
mailing list