title: Gulp rollup babel error - Cannot read property 'preserveSynlinks' / 'rollupVersion of undefined
body: <p>I'm trying to create a gulp task that will use Rollup to compile JavaScript files for modern and legacy using environment variables. I've introduced <code>plugin-node-resolve</code> and <code>plugin-commonjs</code> for the legacy side of things, however whenever I run the script for legacy I get the following error:</p>
  <pre><code>Message:\
      Cannot read property 'preserveSymlinks' of undefined\
  Details:\
      code: PLUGIN_ERROR\
      hook: buildStart\
      domainEmitter: [object Object]\
      domainThrown: false
  </code></pre>
  <p><em>Note:</em> I'm aware that the versions of <code>rollup-plugin-babel</code>, <code>rollup-plugin-commonjs</code> and <code>rollup-plugin-node-resolve</code> are deprecated. I've tried using the @rollup/ variants but when I use these, I get the following error so I must be missing something regardless:</p>
  <pre><code>Message:
      Cannot read property 'rollupVersion' of undefined
  Details:
      domainEmitter: [object Object]
      domainThrown: false
  </code></pre>
  <p>Here are my files:</p>
  <p>gulp task</p>
  <pre><code>const babel = require('rollup-plugin-babel');
  const commonjs = require('rollup-plugin-commonjs');
  const concat = require( 'gulp-concat');
  const gulp = require('gulp');
  const resolve = require('rollup-plugin-node-resolve');
  const rollup = require( 'gulp-rollup');
  
  const library = require('./library');
  
  
  module.exports = () =&gt; {
      
      process.env.NODE_ENV = process.env.BROWSER;
  
          const rollupConfig = {
          allowRealFiles: true,
          input: library.getInputPath('scripts'),
          output: {'format': 'iife'},
          plugins: [
              babel()
          ],
          onwarn(warning, warn) {
              if (warning.code === 'THIS_IS_UNDEFINED') return;
              warn(warning);
          }
      };
  
      if (process.env.BROWSER === 'legacy') {
          rollupConfig.plugins = [
              ...rollupConfig.plugins,
              resolve({
                  jsnext: true,
                  main: true,
                  browser: true
              }),
              commonjs(),
          ];
      }
  
      gulp.task('build:scripts', gulp.series('lint:scripts', () =&gt; {   
          const inputPath = library.getInputPath('scripts');
          const outputPath = library.getOutputPath('scripts');
          const outputFile = library.getFileName('scripts');
  
          return gulp.src(inputPath)
              .pipe(rollup(rollupConfig))
              .pipe(concat(outputFile))
              .pipe(gulp.dest(outputPath));
      }));
  }
  </code></pre>
  <p>.babelrc:</p>
  <pre><code>{
      &quot;exclude&quot;: &quot;node_modules/**&quot;,
      &quot;env&quot;: {
          &quot;modern&quot;: {
              &quot;plugins&quot;: [
                  &quot;@babel/plugin-proposal-class-properties&quot;
              ]
          },
          &quot;legacy&quot;: {
              &quot;presets&quot;: [
                  &quot;@babel/preset-env&quot;
              ],
              &quot;plugins&quot;: [
                  &quot;@babel/plugin-proposal-class-properties&quot;
              ]
          }
      }
  }
  </code></pre>