Working on vue2 to vue3 migration, found the problem ‘’Unexpected token 'export'‘’

60 Views Asked by At

During my migration from vue2 to vue3, while running the application, I found an error line in the node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js file, which reads SyntaxError: Unexpected token 'export' The content of the error file reads

/* eslint-disable no-var */
// This file is imported into lib/wc client bundles.

if (typeof window !== 'undefined') {
  var currentScript = window.document.currentScript
  if (process.env.NEED_CURRENTSCRIPT_POLYFILL) {
    var getCurrentScript = require('@soda/get-current-script')
    currentScript = getCurrentScript()

    // for backward compatibility, because previously we directly included the polyfill
    if (!('currentScript' in document)) {
      Object.defineProperty(document, 'currentScript', { get: getCurrentScript })
    }
  }

  var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/)
  if (src) {
    __webpack_public_path__ = src[1] // eslint-disable-line
  }
}

// Indicate to webpack that this file can be concatenated
export default null

I'd like to solve the problem without modifying the code in this file, as I'm sharing the code with others, so I'm trying not to modify the code in the node_modules directory

0

There are 0 best solutions below