Meituan-Dianping/mpvue · error

It seems you are using the standalone build of Vue.js in an

Error message

It seems you are using the standalone build of Vue.js in an environment with Content Security Policy that prohibits unsafe-eval. The template compiler cannot work in this environment. Consider relaxing the policy to allow unsafe-eval or pre-compiling your templates into render functions.

What it means

Error "It seems you are using the standalone build of Vue.js in an environment with Content Security Policy that prohibits unsafe-eval. The template compiler cannot work in this environment. Consider relaxing the policy to allow unsafe-eval or pre-compiling your templates into render functions." thrown in Meituan-Dianping/mpvue.

Source

Thrown at src/compiler/to-function.js:39

  const cache: {
    [key: string]: CompiledFunctionResult;
  } = Object.create(null)

  return function compileToFunctions (
    template: string,
    options?: CompilerOptions,
    vm?: Component
  ): CompiledFunctionResult {
    options = options || {}

    /* istanbul ignore if */
    if (process.env.NODE_ENV !== 'production') {
      // detect possible CSP restriction
      try {
        new Function('return 1')
      } catch (e) {
        if (e.toString().match(/unsafe-eval|CSP/)) {
          warn(
            'It seems you are using the standalone build of Vue.js in an ' +
            'environment with Content Security Policy that prohibits unsafe-eval. ' +
            'The template compiler cannot work in this environment. Consider ' +
            'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
            'templates into render functions.'
          )
        }
      }
    }

    // check cache
    const key = options.delimiters
      ? String(options.delimiters) + template
      : template
    if (cache[key]) {
      return cache[key]
    }

View on GitHub (pinned to 6c5d78ee04)

Solutions

  1. Relax the CSP to allow 'unsafe-eval' for script-src
  2. Precompile templates into render functions using vue-loader / vueify so the runtime compiler is never invoked
  3. Switch to the runtime-only build which has no compiler and avoids new Function entirely
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/compiler/to-function.js:39 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02). Data as JSON: /api/errors/f1b07b2d146c357e. Report an issue: GitHub.