marko-js / examples

55 stars 36 forks source link

webpack-express example is broken for "legacy" browsers #19

Closed vwong closed 3 years ago

vwong commented 3 years ago

Overview

The webpack build for legacy browsers raises the following

Uncaught ReferenceError: regeneratorRuntime is not defined

Steps to reproduce

DylanPiercey commented 3 years ago

@vwong we opted to remove babel/postcss and that sort of env setup for these examples since it overly complicates things for new users. On top of that we don't actually test the examples in production like setups like this.

vwong commented 3 years ago

Totally understand the simpler example now...

But in case anyone is interested in the multi-build setup, here's what fixed it in the end for me:

diff --git a/babel.config.js b/babel.config.js
index 970e9ac..d9f8747 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -4,6 +4,7 @@ module.exports = (api) => {
   const env = api.caller((it) => it.env);

   return {
+    sourceType: "unambiguous",
     presets: [
       [
         "@babel/env",
@@ -13,6 +14,7 @@ module.exports = (api) => {
       ],
     ],
     plugins: [
+      "@babel/plugin-transform-runtime",
       [
         "babel-plugin-root-import",
         {
diff --git a/package.json b/package.json
index 48f0f08..8d70b3b 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,9 @@
   },
   "devDependencies": {
     "@babel/core": "^7.15.5",
+    "@babel/plugin-transform-runtime": "^7.15.0",
     "@babel/preset-env": "^7.15.6",
+    "@babel/runtime": "^7.15.4",
     "@marko/compiler": "^5.15.10",
     "@marko/prettyprint": "^3.0.1",
     "@marko/webpack": "^9.1.0",