Open semoal opened 5 years ago
Can you provide the rollup configuration file?
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];
same issue here
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 https://github.com/riot/rollup-plugin-riot/commit/aada8ae855e93ac5ec5019cd2e21503251fc2279 for an example fix by another rollup plugin.
It would be really nice to see this resolved. I currently can't generate source maps for my minified scripts.
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