-
Notifications
You must be signed in to change notification settings - Fork 407
Prepare package for bundling in Atom #640
Conversation
331a1c2 to
d14450f
Compare
| return instance; | ||
| } | ||
|
|
||
| constructor(Strategy = strategies.find(strat => strat.isValid())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this check to the first time we actually try to use the strategy saves around ~100ms on the package's initial render (called from activate).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option might be to default to the real Keytar strategy and toggle to the shelling-out one with an environment variable or a (hidden?) config setting. Annoying for those of us who run master, but it'd keep us from paying any performance penalty for the common case of being bundled in a proper Atom distro.
cc625f9 to
9ad8629
Compare
This ensures that the instance is available before any consume* or deserialize* hooks are called
|
This now requires only the following additions to the snapshot creation script in atom/atom when we're ready to bundle: diff --git a/script/lib/generate-startup-snapshot.js b/script/lib/generate-startup-snapshot.js
index 26761fc69..9eaa5f59c 100644
--- a/script/lib/generate-startup-snapshot.js
+++ b/script/lib/generate-startup-snapshot.js
@@ -27,6 +27,7 @@ module.exports = function (packagedAppPath) {
modulePath.endsWith('.node') ||
coreModules.has(modulePath) ||
(relativePath.startsWith(path.join('..', 'src')) && relativePath.endsWith('-element.js')) ||
+ relativePath.startsWith(path.join('..', 'node_modules', 'dugite')) ||
relativePath == path.join('..', 'exports', 'atom.js') ||
relativePath == path.join('..', 'src', 'electron-shims.js') ||
relativePath == path.join('..', 'src', 'safe-clipboard.js') ||
@@ -37,6 +38,7 @@ module.exports = function (packagedAppPath) {
relativePath == path.join('..', 'node_modules', 'cson-parser', 'node_modules', 'coffee-script', 'lib', 'coffee-script', 'register.js') ||
relativePath == path.join('..', 'node_modules', 'decompress-zip', 'lib', 'decompress-zip.js') ||
relativePath == path.join('..', 'node_modules', 'debug', 'node.js') ||
+ relativePath == path.join('..', 'node_modules', 'fs-extra', 'lib', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'git-utils', 'lib', 'git.js') ||
relativePath == path.join('..', 'node_modules', 'glob', 'glob.js') ||
relativePath == path.join('..', 'node_modules', 'graceful-fs', 'graceful-fs.js') ||
@@ -47,6 +49,8 @@ module.exports = function (packagedAppPath) {
relativePath == path.join('..', 'node_modules', 'less', 'lib', 'less-node', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'less', 'node_modules', 'graceful-fs', 'graceful-fs.js') ||
relativePath == path.join('..', 'node_modules', 'minimatch', 'minimatch.js') ||
+ relativePath == path.join('..', 'node_modules', 'node-fetch', 'lib', 'fetch-error.js') ||
+ relativePath == path.join('..', 'node_modules', 'nsfw', 'node_modules', 'fs-extra', 'lib', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'superstring', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'oniguruma', 'lib', 'oniguruma.js') ||
relativePath == path.join('..', 'node_modules', 'request', 'index.js') || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
| import React from 'react'; | ||
|
|
||
| import {Point, Emitter} from 'atom'; | ||
| import {Point} from 'atom'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, this import still works? I thought you'd meant that none of the Atom imports would work properly when bundled. Does it just have to do with the timing of when Emitter and CompositeDisposable are installed in the Atom global?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use Point after activation, so it works fine. We had to bring in event-kit for Emitter and friends in other places, so it made sense to replace it package-wide.
| import {CompositeDisposable} from 'event-kit'; | ||
|
|
||
| import {GitProcess} from 'git-kitchen-sink'; | ||
| import {GitProcess} from 'dugite'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks for getting this upgrade in here 😄
| } | ||
|
|
||
| return DUGITE_PATH; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 cool, cool
| } | ||
|
|
||
| export function deleteFileOrFolder(path) { | ||
| export function deleteFileOrFolder(fileOrFolder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 I always do this. "path" is such a natural name to use as a variable...
| return instance; | ||
| } | ||
|
|
||
| constructor(Strategy = strategies.find(strat => strat.isValid())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option might be to default to the real Keytar strategy and toggle to the shelling-out one with an environment variable or a (hidden?) config setting. Annoying for those of us who run master, but it'd keep us from paying any performance penalty for the common case of being bundled in a proper Atom distro.
| } | ||
| } else { | ||
| return this.props.maximumCharacterLimit; | ||
| return this.props.maximumCharacterLimit || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There are a bunch of changes necessary to support snapshotting in Atom. The snapshot will walk the require graph and pull in all the files to the snapshot, and then execute them in a raw V8 context. This means we get no
require.resolve, noconsole.*, noatom, etc. So we need to move usage of those types of things until they're actually needed.EmitterandDisposablefromevent-kitinstead ofatomrequire.resolveuntil it's actually neededGithubPackageinstance until the package is activated (because we have noatomto use to pass items into the constructor)getPackageRoot()strategy to launch binsIn conjunction with atom/atom#14131
Fixes #618