borodean / postcss-assets

An asset manager for PostCSS
MIT License
537 stars 32 forks source link

Add dependency message #58

Open ai opened 7 years ago

ai commented 7 years ago

New postcss-loader will support dependency message to notify webpack about imports. So we need to add few lines on every import:

result.messages.push({
  type: 'dependecy',
  parent: currentFilePath,
  file: absoluteFilePath
})

@borodean it is not really necessary for images plugins. But I think it will be good to have it here too.

ai commented 7 years ago

@borodean do you need any help?

borodean commented 7 years ago

@ai sorry for being so slow at support. I guess I need some advice on how to organize the whole support/release process better.

Regarding the issue itself: I'll check it out again this weekend and let everyone know if there is anything standing between the current state and releasing this.

ai commented 7 years ago

Sure, what is your main problem with support/release process?

borodean commented 7 years ago

@ai thanks, I'll create a separate issue on the process improvement.

Regarding this particular feature I've started a branch: https://github.com/assetsjs/postcss-assets/compare/feature/58-dependency-messages. Unfortunately, it doesn't work and I'm being blocked by several thingies:

  1. The problem is that the assets core library provides no way to retrieve the original file path of the resolved asset. I'd be grad if anyone helps me sorting it out and implementing properly. I don't expect myself to have enough time to develop it in the nearest future. However, I'd happily guide anyone who's interested.
  2. What should the parent parameter contain? I haven't found it mentioned in neither postcss-loader source code nor Webpack docs.
  3. Since the plugin delegates its function handling to postcss-function it has no access to the result at the moment output is applied. So, I've tried to collect the messages while resolving functions, and after everything is done push them at once. You may check how it works on that branch. However, I'm concerned about the validity of this approach.
ai commented 7 years ago

parent should contains Node#source.input.file

ai commented 7 years ago

It is not so important right now, we could wait :)