Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

fix: get realpath from __filename instead of __dirname (NS) - #618

Merged
alexander-akait merged 1 commit into
webpack-contrib:masterfrom
samertm:master
Sep 14, 2017
Merged

alexander-akait merged 1 commit into
webpack-contrib:masterfrom
samertm:master

Conversation

@samertm

@samertm samertm commented Aug 31, 2017 •

Copy link
Copy Markdown
Contributor

Without this fix, this plugin doesn't work if your node_modules tree is
made up of real directories, but your files are symlinks. It's admittedly a
weird environment, but that's the environment that the Bazel build
system runs code in, which is the build system we use at Dropbox.

This is the bug:

  • index.js is called from the runfiles directory, and it uses the
    realpath of its directory as the key for a function on the
    loaderContext object.

  • loader.js is called from the bazel-bin/npm directory outside
    of its runfiles (because Webpack escapes the runfiles when it
    calls loaders). It uses the realpath of its directory as a
    key on the loaderContext object, but because it's in a
    different directory from index.js, it can't find the function
    set on the loaderContext by index.js.

The fix is to get the realpath of the filename instead of the
directory so that both files point to the same place.

Without this fix, this plugin doesn't work if your node_modules tree is
made up of directories, but your files are symlinks. It's admittedly a
weird environment, but that's the environment that the Bazel build
system runs code in, which is the build system we use at Dropbox.

This is the bug:

 - index.js is called from the runfiles directory, and it uses the
   realpath of its directory as the key for a function on the
   loaderContext object.

 - loader.js is called from the bazel-bin/npm directory outside
   of its runfiles (because Webpack escapes the runfiles when it
   calls loaders). It uses the realpath of its directory as a
   key on the loaderContext object, but because it's in a
   different directory from index.js, it can't find the function
   set on the loaderContext by index.js.

The fix is to get the realpath of the filename instead of the
directory so that both files point to the same place.
@jsf-clabot

jsf-clabot commented Aug 31, 2017 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Aug 31, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #618 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #618   +/-   ##
=======================================
  Coverage   87.41%   87.41%           
=======================================
  Files           7        7           
  Lines         302      302           
  Branches       68       68           
=======================================
  Hits          264      264           
  Misses         36       36           
  Partials        2        2
Impacted Files Coverage Δ
src/index.js 89.7% <100%> (ø) ⬆️
src/loader.js 88.7% <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 6a660f3...53f9fd6. Read the comment docs.

@michael-ciniawsky michael-ciniawsky changed the title Get extract-text-webpack-plugin to work with Bazel fix: get realpath form __filename instead of __dirname (NS) Aug 31, 2017
@michael-ciniawsky

Copy link
Copy Markdown
Member

@samertm Please sign the CLA in any case by closing and reopening the PR to trigger the CLA Bot again

@michael-ciniawsky michael-ciniawsky added this to the 3.0.1 milestone Aug 31, 2017
@michael-ciniawsky michael-ciniawsky changed the title fix: get realpath form __filename instead of __dirname (NS) fix: get realpath from __filename instead of __dirname (NS) Aug 31, 2017
@joshwiens

Copy link
Copy Markdown
Contributor

@michael-ciniawsky - Pretty benign change, land it as soon as @samertm signs the CLA & i'll get a patch version out to npm.

@samertm

samertm commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

Checking with Dropbox that I can sign the NDA, I'll get back to you soon!

@joshwiens

Copy link
Copy Markdown
Contributor

@samertm - CLA not NDA if that makes a difference. https://js.foundation/CLA

It's pretty concise, in summary ... It's your contribution & you understand the OSS license for this repo / org.

@samertm

samertm commented Sep 2, 2017

Copy link
Copy Markdown
Contributor Author

Hey! Just a heads up, I probably won't get permission to sign the CLA until next week.

@TheLarkInn

Copy link
Copy Markdown

No worries. If it helps we've had other googlers get approved for other repos but like MS I'm sure it's a per repo basis. No rush.

@samertm

samertm commented Sep 7, 2017

Copy link
Copy Markdown
Contributor Author

Hey! Sorry for the wait. It seems like the CLA is an individual CLA. Do you all have a corporate CLA that someone at Dropbox could sign and list me as an authorized contributor?

Thanks!

@sokra

sokra commented Sep 8, 2017

Copy link
Copy Markdown
Member

Do you all have a corporate CLA that someone at Dropbox could sign and list me as an authorized contributor?

@kborchers Do we have this?

@kborchers

Copy link
Copy Markdown

@sokra @samertm We do not have an automated system for corporate CLAs. We did try to work really hard with a number of organizations to ensure that our individual CLA would be acceptable for employees to sign and have many organizations that normally require a corporate CLA allowing their employees to sign the individual CLA. For reference, we currently have no active corporate CLAs with any organization right now across all JS Foundation projects as the individual CLA has been deemed acceptable.

That said, if Dropbox does insist on a corporate CLA, we can have legal draft one for approval by Dropbox legal. Once approved, there is then a manual process to add contributors (or remove users if they leave Dropbox) to the approved list by getting a signed addendum from Dropbox each time they want to authorize one or more GitHub accounts to contribute under their corporate CLA. As you can see, it is definitely much easier for everyone if we can use the individual CLA but we are happy to work with Dropbox if that is what they prefer.

@alexander-akait

Copy link
Copy Markdown
Member

@samertm friendly ping

@michael-ciniawsky

Copy link
Copy Markdown
Member

@samertm Could someone take this over in case there is no way for you to sign the CLA atm ?

@samertm

samertm commented Sep 13, 2017

Copy link
Copy Markdown
Contributor Author

Hey! Sorry this is taking so long. I'm pretty sure I'll be able to sign it, but things are moving a bit slow on getting permission to do so.

@samertm

samertm commented Sep 14, 2017

Copy link
Copy Markdown
Contributor Author

Hey! I just signed the CLA, sorry about the wait :)

@alexander-akait
alexander-akait merged commit 8de6558 into webpack-contrib:master Sep 14, 2017
@michael-ciniawsky michael-ciniawsky removed this from the 3.0.2 milestone Oct 19, 2017
gfl-chris added a commit to zenreach/extract-text-webpack-plugin that referenced this pull request Oct 24, 2018
gfl-chris added a commit to zenreach/extract-text-webpack-plugin that referenced this pull request Dec 5, 2018
gfl-chris added a commit to zenreach/extract-text-webpack-plugin that referenced this pull request Dec 5, 2018
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.

8 participants