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

Warnings show incorrect file info (css string with map file) #1388

Open
glenn2223 opened this issue Jan 20, 2021 · 3 comments
Open

Warnings show incorrect file info (css string with map file) #1388

glenn2223 opened this issue Jan 20, 2021 · 3 comments

Comments

@glenn2223
Copy link

My issue is specifically related to the grid: "autoplace" option. But I'd imagine it applies anywhere a warning is raised.

Actual warning snippet:

  • Line: 1
  • Column: 10
  • File: c:\Path\Sample\_AutoprefixExample\File-With-Import.scss (from node.source.input.file)

Expected warning snippet:

  • Line: 2
  • Column: 4
  • File: c:\Path\Sample\_AutoprefixExample\_import-me.scss

Code

const 
    prefixer = postcss(
            autoprefixer({
                overrideBrowserslist: [
                    '> 0.5%'
                    'last 2 versions'
                    'Firefox ESR'
                    'not dead'
                ],
                grid: "autoplace",
            })
        ),
    result = 
        await prefixer.process(
            "div.Test{grid-template-columns:1fr 3fr}",
            {
                from: 'c:\\Path\\Sample\\_AutoprefixExample\\File-With-Import.scss',
                to: 'c:\\Path\\Sample\\Assets\\Style\\File-With-Import.css',
                map: {
                    inline: false,
                    prev: map, // <-- See map below
                },
            }
        );

result.warnings().forEach((warn) => {
    const
        file = warn.node.source.input.file,
        line = warn.line,
        column = warn.column;
});

MAP

{
    "version":3,
    "sourceRoot":"",
    "sources":["../../_AutoprefixExample/_import-me.scss"],
    "names":[],
    "mappings":"AAAA,SACI",
    "file":"file:///c:/Path/Sample/_AutoprefixExample/File-With-Import.css"
}

File-With-Import.scss

@import 'import-me'

_import-me.scss

div.Test {
    grid-template-columns: 1fr 3fr;
}
@ai
Copy link
Member

ai commented Jan 20, 2021

Good idea. Do you want to send PR?

@glenn2223
Copy link
Author

I'm happy to take a look when I can. Where's a good place to start?
Rather than trundling through all the files, can I ask: where are the warnings raised and maps parsed?

glenn2223 added a commit to glenn2223/vscode-live-sass-compiler that referenced this issue Jan 20, 2021
When `generateMap` is `false` the error returned by autoprefixer was `undefined` instead of the file path.

**Known issue**
Autoprefixer does not honour actual error location (from map). Created [issue](postcss/autoprefixer#1388)
@ai
Copy link
Member

ai commented Jan 20, 2021

  1. Find all .warn( calls in Autoprefixer sources.
  2. Check Node#warn() in PostCSS. It should use the node origin. Debug why it is not happening.

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

No branches or pull requests

2 participants