Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Enable snapshot - #37

Merged
as-cii merged 3 commits into
masterfrom
as-support-snapshot
Mar 3, 2017
Merged

as-cii merged 3 commits into
masterfrom
as-support-snapshot

Conversation

@as-cii

@as-cii as-cii commented Mar 1, 2017

Copy link
Copy Markdown
Contributor

This pull request changes fs-plus so that it can be required while generating a v8 snapshot. It does so by:

  1. Using a Proxy object instead of creating a new object containing both fs-plus and fs methods. The nice thing about this approach is that it doesn't break the API which, as a result, allows us to not change the callers of fs-plus in Atom.
  2. Changing resolveOnLoadPath to use module.paths only if present. In the case of a snapshot we won't be able to provide the absolute resolution paths at require-time (i.e. they depend on the location where Atom is installed at and the snapshot is generated on a CI server), but we can still resolve them by using snapshotResult.entryPointDirPath.

The downside of Proxy objects is that they're ~2x slower, so if you repeatedly call fs-plus functions there's a chance performance will regress. On the other hand, when dealing with the file system what's usually slow is I/O and therefore the overhead of proxies might be negligible.

@as-cii

as-cii commented Mar 2, 2017

Copy link
Copy Markdown
Contributor Author

/cc: @nathansobo @maxbrunsfeld

@as-cii as-cii mentioned this pull request Mar 2, 2017
13 tasks done
@nathansobo

Copy link
Copy Markdown
Contributor

Looks cool. Nice solution. I'm a bit confused about the whole entryPointPathDir point... what is an example value for that field on the snapshot?

@as-cii
as-cii force-pushed the as-support-snapshot branch from 9be3829 to 90dd485 Compare March 2, 2017 15:14
@as-cii

as-cii commented Mar 2, 2017

Copy link
Copy Markdown
Contributor Author

I'm a bit confused about the whole entryPointPathDir point... what is an example value for that field on the snapshot?

Originally I was using it because module.paths isn't available if fs-plus is snapshotted. An example value for it would be /Applications/Atom.app/Contents/Resources/app/static and it would be set in static/index.js. However, now that we have decided to drop support for asar, I think we can simply use process.resourcesPath instead (90dd485).

@as-cii
as-cii merged commit d6494bb into master Mar 3, 2017
@as-cii
as-cii deleted the as-support-snapshot branch March 3, 2017 15:42
ahutchings added a commit to jurassix/atom-javascript-refactor that referenced this pull request Mar 4, 2017
As of version 2.10.0, fs-plus exports a Proxy object which cannot be automocked by Jest.

See atom/fs-plus#37.
This was referenced Mar 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants