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

Sourcemap warning #1

Open
semoal opened this issue Jan 11, 2019 · 5 comments · May be fixed by #8
Open

Sourcemap warning #1

semoal opened this issue Jan 11, 2019 · 5 comments · May be fixed by #8

Comments

@semoal
Copy link

semoal commented Jan 11, 2019

When run: rollup -c and rollup -c -w

It says:
(!) Broken sourcemap
https://rollupjs.org/guide/en#warning-sourcemap-is-likely-to-be-incorrect
Plugins that transform code (such as 'banner') should generate accompanying sourcemaps

Rollup version: 1.0.2

@yingye
Copy link
Owner

yingye commented Jan 17, 2019

Can you provide the rollup configuration file?

@semoal
Copy link
Author

semoal commented Jan 17, 2019

import path from 'path';
import nodeResolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import commonjs from 'rollup-plugin-commonjs';
import filesize from 'rollup-plugin-filesize';
import visualizer from 'rollup-plugin-visualizer';
import { terser } from 'rollup-plugin-terser';
import banner from 'rollup-plugin-banner';

import pkg from './package.json';

const BANNER = `
  @license
	xxx - xxx.js - ${pkg.version}
	Released under the ISC License!.
`;

const SOURCE_DIR = path.resolve(__dirname, 'src');
const DIST_DIR = path.resolve(__dirname, 'dist');
const BUILD_NAME = 'gergr';

const baseConfig = {
  input: `${SOURCE_DIR}/index.js`,
  plugins: [
    replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
    nodeResolve({
      jsnext: true
    }),
    babel({
      exclude: '**/node_modules/**'
    }),
    banner(BANNER),
    filesize()
  ]
};

const esConfig = Object.assign({}, baseConfig, {
  output: {
    file: `${DIST_DIR}/${BUILD_NAME}.es.js`,
    format: 'esm',
    sourcemap: true
  },
  external: [...Object.keys(pkg.peerDependencies), ...Object.keys(pkg.dependencies)]
});

const cjsConfig = Object.assign({}, esConfig, {
  output: {
    file: `${DIST_DIR}/${BUILD_NAME}.cjs.js`,
    format: 'cjs',
    sourcemap: true
  },
  plugins: [
    ...esConfig.plugins,
    visualizer({
      filename: './stats/stats.html',
      title: 'gregreger - Stats'
    })
  ]
});

const globals = {
  react: 'React',
  'react-dom': 'ReactDom',
  'styled-components': 'styled'
};

const umdConfig = Object.assign({}, baseConfig, {
  output: {
    name: 'gergerg',
    file: `${DIST_DIR}/${BUILD_NAME}.js`,
    exports: 'named',
    sourcemap: false,
    format: 'umd',
    globals
  },
  external: Object.keys(globals),
  plugins: [...baseConfig.plugins, nodeResolve({ browser: true }), commonjs()]
});

const minConfig = Object.assign({}, umdConfig, {
  output: {
    ...umdConfig.output,
    sourcemap: true,
    file: `${DIST_DIR}/${BUILD_NAME}.min.js`
  },
  plugins: [
    terser({
      ie8: true,
      safari10: true,
      numWorkers: 1,
      compress: {
        pure_getters: true,
        unsafe: true,
        unsafe_comps: true,
        warnings: false
      },
      output: {
        comments(node, comment) {
          const { type, value } = comment;
          if (type === 'comment2') return /@preserve|@license|@cc_on/i.test(value);
          return false;
        }
      }
    }),
    ...umdConfig.plugins
  ]
});

export default [esConfig, cjsConfig, umdConfig, minConfig];

@luizbills
Copy link

same issue here

@hugmanrique
Copy link

hugmanrique commented Jun 16, 2019

I'm getting the same issue (https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect).

Here's a smaller repro rollup config file:

import banner from 'rollup-plugin-banner';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/index.js',
    format: 'cjs',
    sourcemap: true
  },
  plugins: [
    // Declare shebang
    banner('#/usr/bin/env node')
  ]
};

See riot/rollup-plugin-riot@aada8ae for an example fix by another rollup plugin.

@stropho stropho linked a pull request Mar 2, 2020 that will close this issue
@GreenImp
Copy link

GreenImp commented Aug 7, 2020

It would be really nice to see this resolved. I currently can't generate source maps for my minified scripts.

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.

5 participants