Skip to content

Add support for the insert option #459

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

Closed
wants to merge 3 commits into from

Conversation

giuseppeg
Copy link

@giuseppeg giuseppeg commented Oct 31, 2019

This PR contains a:

New feature.

Motivation / Use-Case

This new option mirrors the behavior of style-loader which allows users to pass a custom insert function that takes care of inserting chunks. This is particularly useful when the initiator is in the parent window but the application renders inside of an iframe.

Breaking Changes

None. This change is backwards compatible: when this option is not provided the plugin will keep inserting link tags as before i.e. to the document's head.

Additional Info

I found a similar PR #371 but the proposed API forces the user to return an element that the plugin will use as insertion point.

@jsf-clabot
Copy link

jsf-clabot commented Oct 31, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for work, need add tests

@giuseppeg
Copy link
Author

@evilebottnawi thank you for taking a look. Can you be a bit more specific as for what kind of extra tests we need to merge this PR? I have added some already but I wasn't quite sure if those were enough or the right way to test this feature.

@alexander-akait
Copy link
Member

alexander-akait commented Nov 5, 2019

We need test case, here examples https://github.com/webpack-contrib/mini-css-extract-plugin/tree/master/test/cases, just add test for string and Function

@giuseppeg
Copy link
Author

Should I just create a new folder in cases? If so I thought that those kind of tests are not end to end and don't test runtime (eg. insert a link tag on a page) - please correct me if I am wrong.

@alexander-akait
Copy link
Member

Should I just create a new folder in cases?

yes, insert-string and insert-function

If so I thought that those kind of tests are not end to end and don't test runtime (eg. insert a link tag on a page)

Let's implement this, it is not difficult

@yisar
Copy link

yisar commented Dec 2, 2019

Is there any progress here? It's not very difficult, but it's urgent.

@giuseppeg
Copy link
Author

@132yse I might have time to work on this sometime next week. If you need it earlier please go ahead and take over it, you'd just need to add tests.

@codecov
Copy link

codecov bot commented Dec 12, 2019

Codecov Report

Merging #459 into master will increase coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #459      +/-   ##
==========================================
+ Coverage   88.65%   88.81%   +0.15%     
==========================================
  Files           5        5              
  Lines         423      429       +6     
  Branches       92       97       +5     
==========================================
+ Hits          375      381       +6     
  Misses         46       46              
  Partials        2        2              
Impacted Files Coverage Δ
src/loader.js 89.01% <ø> (ø)
src/index.js 88.58% <100.00%> (+0.32%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7eda97...c68ae52. Read the comment docs.

expect(computedValue).toBe('');

const script = document.createElement('script');
script.src = outputPath;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evilebottnawi it seems that webpack is not emitting this file and it 404s. Also I am not sure jsdom supports getComputedStyle. In that case I think we either get rid of this test or need to set up something like Puppeteer which IMO is out of scope.

@ankurbigcomm
Copy link

ankurbigcomm commented Apr 6, 2020

@giuseppeg @evilebottnawi Any Update here?! We might need this for one of our use cases. Any possibility this is getting merged soon?

@giuseppeg
Copy link
Author

I think @ScriptedAlchemy took over this but his PR is blocked.

@ScriptedAlchemy
Copy link
Contributor

Merge my PR into your branch if needed. I’m not blocked just ran out of time to perform the last requests. Started working on module Federation and that’s a monster that has taken all my capacity

@ScriptedAlchemy
Copy link
Contributor

If you need it now. Extract css has us it for months. https://github.com/faceyspacey/extract-css-chunks-webpack-plugin

@alexander-akait
Copy link
Member

#609 improved

@ScriptedAlchemy
Copy link
Contributor

Yaaaay

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

Successfully merging this pull request may close these issues.

6 participants