Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import() statement within a switch block is broken on 0.11.0 #1082

Closed
avendiart opened this issue Mar 29, 2021 · 1 comment
Closed

import() statement within a switch block is broken on 0.11.0 #1082

avendiart opened this issue Mar 29, 2021 · 1 comment

Comments

@avendiart
Copy link

Source code (excerpt):

function fetchIcon(icon) {
    switch (icon) {
        case 'arrow-left':
            return import("../../../assets/icons/arrow-left.svg");
        case 'arrow-right':
            return import("../../../assets/icons/arrow-right.svg");
        case 'check-mark':
            return import("../../../assets/icons/check-mark.svg");
        case 'chevron-down':
            return import("../../../assets/icons/chevron-down.svg");
        case 'chevron-left':
            return import("../../../assets/icons/chevron-left.svg");
        case 'chevron-right':
            return import("../../../assets/icons/chevron-right.svg");
        case 'chevron-both':
            return import("../../../assets/icons/chevron-both.svg");
        case 'close':
            return import("../../../assets/icons/close.svg");
        case 'logo-prosieben-white':
            return import("../../../assets/icons/logo-prosieben-white.svg");
        case 'logo-prosieben':
            return import("../../../assets/icons/logo-prosieben.svg");
        case 'logo-sat1-white':
            return import("../../../assets/icons/logo-sat1-white.svg");
        case 'logo-sat1':
            return import("../../../assets/icons/logo-sat1.svg");
        case 'menu':
            return import("../../../assets/icons/menu.svg");
        case 'notification':
            return import("../../../assets/icons/notification.svg");
        case 'play':
            return import("../../../assets/icons/play.svg");
        case 'user':
            return import("../../../assets/icons/user.svg");
        case 'fullscreen':
            return import("../../../assets/icons/fullscreen.svg");
        default:
            throw new Error('Unknown icon specified');
    }
}

0.10.0 Build:

  function xT(e) {
    switch (e) {
      case 'arrow-left':
        return Promise.resolve().then(() => C(Lv()))
      case 'arrow-right':
        return Promise.resolve().then(() => C(jv()))
      case 'check-mark':
        return Promise.resolve().then(() => C(Bv()))
      case 'chevron-down':
        return Promise.resolve().then(() => C(Hv()))
      case 'chevron-left':
        return Promise.resolve().then(() => C(Wv()))
      case 'chevron-right':
        return Promise.resolve().then(() => C(zv()))
      case 'chevron-both':
        return Promise.resolve().then(() => C(Yv()))
      case 'close':
        return Promise.resolve().then(() => C(Jv()))
      case 'logo-prosieben-white':
        return Promise.resolve().then(() => C(Xv()))
      case 'logo-prosieben':
        return Promise.resolve().then(() => C(eb()))
      case 'logo-sat1-white':
        return Promise.resolve().then(() => C(rb()))
      case 'logo-sat1':
        return Promise.resolve().then(() => C(ab()))
      case 'menu':
        return Promise.resolve().then(() => C(ob()))
      case 'notification':
        return Promise.resolve().then(() => C(lb()))
      case 'play':
        return Promise.resolve().then(() => C(cb()))
      case 'user':
        return Promise.resolve().then(() => C(fb()))
      case 'fullscreen':
        return Promise.resolve().then(() => C(yb()))
      default:
        throw new Error('Unknown icon specified')
    }
  }

0.11.0 Build:

  function TT(e) {
    switch (e) {
      case 'arrow-left':
        returnPromise.resolve().then(() => C(Lv()))
      case 'arrow-right':
        returnPromise.resolve().then(() => C(jv()))
      case 'check-mark':
        returnPromise.resolve().then(() => C(Bv()))
      case 'chevron-down':
        returnPromise.resolve().then(() => C(Hv()))
      case 'chevron-left':
        returnPromise.resolve().then(() => C(Wv()))
      case 'chevron-right':
        returnPromise.resolve().then(() => C(zv()))
      case 'chevron-both':
        returnPromise.resolve().then(() => C(Yv()))
      case 'close':
        returnPromise.resolve().then(() => C(Jv()))
      case 'logo-prosieben-white':
        returnPromise.resolve().then(() => C(Xv()))
      case 'logo-prosieben':
        returnPromise.resolve().then(() => C(eb()))
      case 'logo-sat1-white':
        returnPromise.resolve().then(() => C(rb()))
      case 'logo-sat1':
        returnPromise.resolve().then(() => C(ab()))
      case 'menu':
        returnPromise.resolve().then(() => C(ob()))
      case 'notification':
        returnPromise.resolve().then(() => C(lb()))
      case 'play':
        returnPromise.resolve().then(() => C(cb()))
      case 'user':
        returnPromise.resolve().then(() => C(fb()))
      case 'fullscreen':
        returnPromise.resolve().then(() => C(yb()))
      default:
        throw new Error('Unknown icon specified')
    }
  }

Build script:

const path = require('path')

require('esbuild').build({
  platform: 'browser',
  entryPoints: [path.resolve(__dirname, '../src/client.tsx')],
  outdir: path.resolve(__dirname, '../build/client'),
  publicPath: '/',
  bundle: true,
  sourcemap: true,
  treeShaking: true,
  minify: true,
  loader: {
    '.svg': 'file',
    '.woff': 'file',
    '.woff2': 'file',
  },
  watch: process.env.WATCH === 'true',
  inject: [path.resolve(__dirname, './react-shim.js')],
  define: {
    'process.env.NODE_ENV': '"production"',
  },
})
@evanw evanw closed this as completed in e402940 Mar 29, 2021
@evanw
Copy link
Owner

evanw commented Mar 29, 2021

Thanks for the report! This will be fixed in the next release, and now has test coverage to avoid breaking again in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants