Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

fix(cjs): export raw value #183

Merged
merged 2 commits into from
Sep 30, 2017
Merged

fix(cjs): export raw value #183

merged 2 commits into from
Sep 30, 2017

Conversation

alexander-akait
Copy link
Member

@alexander-akait alexander-akait commented Jul 27, 2017

We use "main": "dist/cjs.js" in package.json, but default(https://github.com/webpack-contrib/file-loader/blob/master/src/cjs.js#L1) doesn't contain raw value so file-loader doesn't work correctly.

@codecov
Copy link

codecov bot commented Jul 27, 2017

Codecov Report

Merging #183 into master will increase coverage by 3.03%.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #183      +/-   ##
========================================
+ Coverage   96.96%   100%   +3.03%     
========================================
  Files           2      2              
  Lines          33     35       +2     
  Branches       16     16              
========================================
+ Hits           32     35       +3     
+ Misses          1      0       -1
Impacted Files Coverage Δ
src/cjs.js 100% <100%> (+100%) ⬆️

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 0c52ae2...f9b839e. Read the comment docs.

src/cjs.js Outdated
@@ -1 +1,4 @@
module.exports = require('./index').default;
const fileLoader = require('./index');
Copy link
Member

Choose a reason for hiding this comment

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

fileLoader => loader 😛

Copy link
Member Author

Choose a reason for hiding this comment

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

@michael-ciniawsky 👍 done

@michael-ciniawsky michael-ciniawsky changed the title fix: exports raw value in cjs fix(cjs): export raw value Jul 27, 2017
@michael-ciniawsky michael-ciniawsky added this to the 1.0.0 milestone Jul 27, 2017
src/cjs.js Outdated
const fileLoader = require('./index');

module.exports = fileLoader.default;
module.exports.raw = fileLoader.raw;

Choose a reason for hiding this comment

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

This is mutating fileLoader.default... 😕

Maybe it could be better to write the workaround in index.js itself, with a comment that it's a workaround for the commonjs export.

They'll both do the same thing, and I guess technically put the cjs change outside of the cjs wrapper, but I'd prefer that to being mutated from outside.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Kovensky Perhaps, but on the other hand, I would not want to add workarounds to the loader code, because it can be misleading. In any case, I'm open to ideas, I'll be glad to see another solution

Copy link
Member

@michael-ciniawsky michael-ciniawsky Jul 28, 2017

Choose a reason for hiding this comment

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

@Kovensky What are potential issues with mutating loader.default ? Handling the Module System related stuff in the wrapper would be 👍 if possible 🙃

@alexander-akait
Copy link
Member Author

@michael-ciniawsky just ensure tests are good, also npm have bug with node 4.3 😞 npm/npm#18395

beheh added a commit to HearthSim/twitch-hdt-frontend that referenced this pull request Sep 23, 2017
Use hotfixed file-loader for now, until webpack-contrib/file-loader#183
is released.
@brianhelba
Copy link

@evilebottnawi See #204 for a fix to tests.

@michael-ciniawsky
Copy link
Member

@brianhelba This needs to be updated in webpack-defaults instead as it is the boilerplate for all repos

@d3viant0ne @evilebottnawi If it is the only known failure blocking, can we merge the fix regardless of the npm CI incompat for now and fix it in a follow up PR? Setting raw is fairly important for the loader

@brianhelba
Copy link

@michael-ciniawsky I agree, I'd like to merge this PR ASAP, even without the fix in #204. The CI tests are already failing on master, so this won't make anything worse (and this still passes tests on everything except Node.js 4.3). However, this does fix a very serious regression, which makes file-loader totally unusable for binary files (e.g. images) right now.

@d3viant0ne @evilebottnawi Is that ok?

@joshwiens joshwiens merged commit daeff0e into master Sep 30, 2017
@joshwiens joshwiens deleted the fix-exports-raw-value branch September 30, 2017 02:39
@joshwiens
Copy link
Member

@brianhelba - [email protected]

@brianhelba
Copy link

Excellent! Thanks for the quick attention and release.

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

Successfully merging this pull request may close these issues.

5 participants