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

Breaks Sourcemaps? #1

Closed
developit opened this Issue Dec 23, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@developit

developit commented Dec 23, 2015

Hi - am I correct in assuming this plugin breaks sourceMaps? It's doing a string transformation on the CSS file. When I add this to my rollup plugin stack I get the following error:

Cannot read property 'split' of undefined
TypeError: Cannot read property 'split' of undefined
    at decode (~proj/node_modules/rollup/www/ROLLUP/rollup/node_modules/sourcemap-codec/dist/sourcemap-codec.es6.js:100:22)
    at ~proj/node_modules/rollup/www/ROLLUP/rollup/src/utils/collapseSourcemaps.js:32:11
    at Array.map (native)
    at ~proj/node_modules/rollup/www/ROLLUP/rollup/src/utils/collapseSourcemaps.js:30:32
    at Array.map (native)
    at collapseSourcemaps (~proj/node_modules/rollup/www/ROLLUP/rollup/src/utils/collapseSourcemaps.js:29:25)
    at Bundle.render (~proj/node_modules/rollup/www/ROLLUP/rollup/src/Bundle.js:256:42)
    at Object.write (~proj/node_modules/rollup/www/ROLLUP/rollup/src/rollup.js:64:32)
    at ~proj/node_modules/rollup/bin/runRollup.js:116:18
    at tryCatch (~proj/node_modules/rollup/www/ROLLUP/rollup/node_modules/es6-promise/lib/es6-promise/-internal.js:182:12)

This is the offending rollup.config.js:

import babel from 'rollup-plugin-babel';
import npm from 'rollup-plugin-npm';
import commonjs from 'rollup-plugin-commonjs';
import postcss from 'rollup-plugin-postcss';

export default {
    entry: 'src/index.js',
    dest: 'bundle.js',
    sourceMap: true,
    format: 'umd',
    plugins: [
        babel({ exclude: 'node_modules/**' }),
        npm({ jsnext: true, main: true }),
        commonjs(),
        postcss()
    ]
};

... note that reordering the plugins doesn't seem to help.

@egoist

This comment has been minimized.

Owner

egoist commented Dec 23, 2015

Thx for feedback, I just disabled generating source-map for Rollup to fix this.

Since this plugin does not extract css into a single file, You can set PostCSS options inline: true to enable inline source-map when developing.

// maybe there should be another plugin which extracts css into a single file for Rollup so that we could use source-map file.

@developit

This comment has been minimized.

developit commented Dec 23, 2015

@egoist I may have stumbled on the answer to why it's throwing: the map returned from postcss is a JSON String, but rollup expects it to be an object. Maybe adding a quick parse() would fix this?
The issue was noticed in the typescript plugin: rollup/rollup#322

@egoist egoist closed this in 4af45f3 Dec 23, 2015

@egoist

This comment has been minimized.

Owner

egoist commented Dec 23, 2015

yep, you are right.

@developit

This comment has been minimized.

developit commented Dec 23, 2015

Awesome, so happy to have this working! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment