You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating a bundle that is meant to be used as a library in the browser. I did this using the--gobal option in the old parcel-bundler. When I migrated to v2 parcel I did this using a target with isLibrary, browser context and esmodule output. In the browser I use <script type="module"> to import it.
<script type="module">
import {VrtxBoxEditor} from "/path/to/box-editor/index.js";
</script>
A production-ready bundle is generated not including development dependencies. The bundle exports VrtxBoxEditor.
This did work when I first migrated to Parcel version 2.12. Later I updated Parcel to 2.14 and it's dependencies and this stopped to work as I expected, as explained below.
It includes development dependencies for React. And inside the generated bundle a check "production"===process.env.NODE_ENV is done which do not work in the browser.
Remove isLibrary and change outputFormat to global. Then I explicitly add VrtxBoxEditor to the global window object so it is available outside the bundle.
window.VrtxBoxEditor = new VrtxBoxEditor();
The text was updated successfully, but these errors were encountered:
I'm experiencing a possible related problem while evolving a poc for a dev server which enables component-based testing on cypress with parcel. Can't add much more, still researching what's going on with missing code at spec builds
Uh oh!
There was an error while loading. Please reload this page.
🐛 bug report
I am creating a bundle that is meant to be used as a library in the browser. I did this using the
--gobal
option in the oldparcel-bundler
. When I migrated to v2 parcel I did this using a target withisLibrary
,browser
context andesmodule
output. In the browser I use<script type="module">
to import it.🎛 Configuration package.json
🤔 Expected Behavior
A production-ready bundle is generated not including development dependencies. The bundle exports VrtxBoxEditor.
This did work when I first migrated to Parcel version 2.12. Later I updated Parcel to 2.14 and it's dependencies and this stopped to work as I expected, as explained below.
😯 Current Behavior
It includes development dependencies for React. And inside the generated bundle a check
"production"===process.env.NODE_ENV
is done which do not work in the browser.💁 Possible Solution
Remove
isLibrary
and changeoutputFormat
to global. Then I explicitly addVrtxBoxEditor
to the globalwindow
object so it is available outside the bundle.The text was updated successfully, but these errors were encountered: