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

import-only files not in sourcemap #400

Open
htho opened this issue Jul 8, 2019 · 6 comments
Open

import-only files not in sourcemap #400

htho opened this issue Jul 8, 2019 · 6 comments

Comments

@htho
Copy link

htho commented Jul 8, 2019

I have file that has only @import rules, but nothing else.
This file can not be found in the sourcemap.
If I add a dummy comment, the file is in the sourcemap.

Maybe this is related to: #81?

I created a minimally working example:
https://github.com/htho/mwe-postcss-import-sourcemap-import-only

@RyanZim
Copy link
Collaborator

RyanZim commented Jul 8, 2019

PR welcome to fix this.

@htho
Copy link
Author

htho commented Jul 8, 2019

Puh.

I wouldn't even know where to start. I have no clue about the interaction between postcss and postcss-import.

@romainmenke
Copy link
Collaborator

If I add a dummy comment, the file is in the sourcemap.

That is the only way to "fix" this.

postcss-import removes @import statements and anything that is imported will be coming from other files.

If a file contains only @import statements it will never be part of the source maps.

We could automatically add a comment with the @import statement as comment text :
/* @import "foo.css" */

But any half decent minifier will scrub comments, re-introducing the issue.


I am also unsure what the use case is.
Technically the file is missing from the source maps, but is this a problem?
Sourcemaps should still work for all other CSS.

If so, which problem?
Are there alternative solutions?

@romainmenke
Copy link
Collaborator

romainmenke commented Aug 10, 2023

We could automatically add a comment with the @import statement as comment text :
/* @import "foo.css" */

esbuild seems to do something like this.


style.css :

@import url("a.css");

a.css :

.box {
	background-color: green;
}

becomes :

/* tests/001-core-features/001/default/a.css */
.box {
  background-color: green;
}

/* tests/001-core-features/001/default/style.css */

@RyanZim RyanZim added enhancement and removed bug labels Aug 11, 2023
@RyanZim
Copy link
Collaborator

RyanZim commented Aug 11, 2023

If someone wants this badly enough they're willing to submit a PR, we can consider it. But I don't see the point of adding it just for the sake of it. So far, one request in ~4 years; doesn't seem to be a common need.

@romainmenke
Copy link
Collaborator

Yeah, I also fail to see the issue.

I don't think the fact that it's missing from a sourcemap is breaking anything or can cause any inconvenience.

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

No branches or pull requests

3 participants