In Parcel 2, calling a function defined in a <script> tag from HTML (i.e. button onclick) leads to a reference error.
{
"name": "parcel2-inline-script",
"version": "1.0.0",
"description": "Shows off a bug with inline scripts in Parcel 2",
"main": "dist/index.html",
"scripts": {
"dev": "parcel src/index.html",
"build": "parcel src/build index.html"
},
"repository": {
"type": "git",
"url": "git+https://github.com/JonathanTroyer/Parcel2-inline-script.git"
},
"author": "Jonathan Troyer",
"license": "MIT",
"bugs": {
"url": "https://github.com/JonathanTroyer/Parcel2-inline-script/issues"
},
"homepage": "https://github.com/JonathanTroyer/Parcel2-inline-script#readme",
"devDependencies": {
"parcel": "^2.0.0-alpha.3.2"
}
}
The function should be run, same as in Parcel
I get Uncaught Reference Error: x is not defined
ยฏ\_(ใ)_/ยฏ It may be related to https://github.com/parcel-bundler/parcel/issues/1618. See also https://github.com/parcel-bundler/parcel/issues/3301
This is blocking me from transitioning an app from Parcel to Parcel 2, as several pages use script tags on the page.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-alpha.3.
| Node | 12.13.0
| npm/Yarn | npm 6.12.0
| Operating System | Windows 10 Pro 1909 build 18363.535
A workaround:
window.test = function ....
Most helpful comment
A workaround: