ampproject / remapping

Remap sequential sourcemaps through transformations to point at the original source code
Apache License 2.0
109 stars 26 forks source link

Maximum call stack size exceeded #163

Closed tony19 closed 2 years ago

tony19 commented 2 years ago

Webpack-based projects (including Vue CLI scaffolded projects, and Quasar projects) are failing with Maximum call stack size exceeded, starting from buildSourceMapTree() and infinitely recursing in build(). This seems to occur when building the source map.

Steps to reproduce:

  1. Scaffold a new Vue CLI project with:

     npx @vue/cli create --default my-vue-app
  2. Change into the source directory with:

    cd my-vue-app
  3. Start the webpack devserver:

    npm run serve
  4. Observe the error in the console.

Call stack
 (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:230)
build (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:206)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:230)
build (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:206)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:230)
build (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:206)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:230)
build (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:206)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:230)
build (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:206)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:230)
build (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:206)
buildSourceMapTree (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:198)
remapping (/Users/tony/src/tmp/test-vue-app123/node_modules/@ampproject/remapping/dist/remapping.umd.js:273)
mergeSourceMap (/Users/tony/src/tmp/test-vue-app123/node_modules/@babel/core/lib/transformation/file/merge-map.js:19)
generateCode (/Users/tony/src/tmp/test-vue-app123/node_modules/@babel/core/lib/transformation/file/generate.js:75)
run (/Users/tony/src/tmp/test-vue-app123/node_modules/@babel/core/lib/transformation/index.js:55)
transform (/Users/tony/src/tmp/test-vue-app123/node_modules/@babel/core/lib/transform.js:25)
step (/Users/tony/src/tmp/test-vue-app123/node_modules/gensync/index.js:261)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/gensync/index.js:273)
async.call.result.err.err (/Users/tony/src/tmp/test-vue-app123/node_modules/gensync/index.js:223)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/gensync/index.js:189)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/@babel/core/lib/gensync-utils/async.js:74)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/gensync/index.js:113)
step (/Users/tony/src/tmp/test-vue-app123/node_modules/gensync/index.js:287)
 (/Users/tony/src/tmp/test-vue-app123/node_modules/gensync/index.js:273)
async.call.result.err.err (/Users/tony/src/tmp/test-vue-app123/node_modules/gensync/index.js:223)

Environment

tony19 commented 2 years ago

A workaround is to configure Webpack's devtool to something other than eval or eval-source-map (e.g., you can pick eval-cheap-source-map):

Vue CLI 5.x:

// vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  configureWebpack: {
    devtool: 'eval-cheap-source-map',
  },
})

Vue CLI 4.x:

// vue.config.js
module.exports = {
  configureWebpack: {
    devtool: 'eval-cheap-source-map',
  },
}
jridgewell commented 2 years ago

Hi @tony19: This is fixed by https://github.com/babel/babel/pull/14274, and released in Babel v7.17.4. Sorry for the breakage!