Jeffrey Heer created ARROW-12734:
------------------------------------
Summary: [JS] Arrow v4.0.0 breaks Snowpack builds
Key: ARROW-12734
URL: https://issues.apache.org/jira/browse/ARROW-12734
Project: Apache Arrow
Issue Type: Bug
Components: JavaScript
Affects Versions: 4.0.0
Reporter: Jeffrey Heer
Snowpack builds break as of Apache Arrow v4.0.0, with the following error:
ReferenceError: Cannot access 'Buffer' before initialization
at eval (eval at <anonymous>
([https://cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports/optimized/apache-arrow.js:6:17]),
<anonymous>:1:1)
at
[https://cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports/optimized/apache-arrow.js:6:17]
I believe this also breaks other bundlers that use hot module replacement, such
as Vite ([https://github.com/vitejs/vite).]
This appears to be caused by the following line of exported code, which makes
potentially problematic use of "eval":
{{const _Buffer = eval("typeof Buffer === 'function' ? Buffer : null");}}
Note that Arrow version 3 works without incident. This error was reported by a
user of the Arquero library ([https://github.com/uwdata/arquero/issues/166)] as
it is breaking their build.
To reproduce, load the following HTML:
{{<!DOCTYPE html>}}
{{<html lang="en">}}
{{ <body>}}
{{ <script type="module">}}
{{ import * as Arrow from "https://cdn.skypack.dev/[email protected]";}}
{{ console.log(Arrow);}}
{{ </script>}}
{{ </body>}}
{{</html>}}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)