-
Notifications
You must be signed in to change notification settings - Fork 574
Bundle and optimize #2139
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
Closed
Bundle and optimize #2139
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
030d448
Start with uncurrying optimization in psc-bundle.
jutaro cb2d966
Adding exports. Administration.
jutaro 928bc32
AST traversal.
jutaro ef45d62
Started replace matching.
jutaro a6890a5
Replace Generation (still buggy).
jutaro 77ebaf1
First working version.
jutaro fc20978
Perform dead code elimination cycle twice.
jutaro 4dda461
Changed cabal.
jutaro f787cc0
Merge remote-tracking branch 'origin/master' into BundleAndOptimize
jutaro 46167e1
Statistics and options.
jutaro e1b2a7c
Start with uncurrying optimization in psc-bundle.
jutaro d50e520
Adding exports. Administration.
jutaro 76f3c1e
AST traversal.
jutaro 2a830c0
Started replace matching.
jutaro 6e7a8e8
Replace Generation (still buggy).
jutaro 2ee93b5
First working version.
jutaro c261dc7
Perform dead code elimination cycle twice.
jutaro 01933b2
Changed cabal.
jutaro bc6975f
Statistics and options.
jutaro e1db9f6
Optimizing for psc >= 0.8.4.0
jutaro e36a11f
Merge remote-tracking branch 'origin/BundleAndOptimize' into BundleAn…
jutaro e89374d
Fixed two bugs.
jutaro 4180c53
Merge remote-tracking branch 'origin/BundleAndOptimize' into 0.9
jutaro f053218
Fixes.
jutaro ce09a2f
fixup!
mgmeier 929d50b
fixup!
mgmeier c85e656
fixup!
mgmeier 116484e
Fixed docu error.
jutaro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ module Main (main) where | |
|
|
||
| import Data.Traversable (for) | ||
| import Data.Version (showVersion) | ||
| import Data.Maybe (fromMaybe) | ||
|
|
||
| import Control.Applicative | ||
| import Control.Monad | ||
|
|
@@ -35,6 +36,7 @@ data Options = Options | |
| , optionsEntryPoints :: [String] | ||
| , optionsMainModule :: Maybe String | ||
| , optionsNamespace :: String | ||
| , optionsShouldUncurry :: Maybe Bool | ||
| } deriving Show | ||
|
|
||
| -- | Given a filename, assuming it is in the correct place on disk, infer a ModuleIdentifier. | ||
|
|
@@ -60,8 +62,7 @@ app Options{..} = do | |
| length js `seq` return (mid, js) -- evaluate readFile till EOF before returning, not to exhaust file handles | ||
|
|
||
| let entryIds = map (`ModuleIdentifier` Regular) optionsEntryPoints | ||
|
|
||
| bundle input entryIds optionsMainModule optionsNamespace | ||
| bundle input entryIds optionsMainModule optionsNamespace (fromMaybe False optionsShouldUncurry) | ||
|
|
||
| -- | Command line options parser. | ||
| options :: Parser Options | ||
|
|
@@ -70,6 +71,7 @@ options = Options <$> some inputFile | |
| <*> many entryPoint | ||
| <*> optional mainModule | ||
| <*> namespace | ||
| <*> (optional (not <$> noShouldUncurry) <|> optional shouldUncurry) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this mean |
||
| where | ||
| inputFile :: Parser FilePath | ||
| inputFile = strArgument $ | ||
|
|
@@ -101,6 +103,18 @@ options = Options <$> some inputFile | |
| <> showDefault | ||
| <> help "Specify the namespace that PureScript modules will be exported to when running in the browser." | ||
|
|
||
|
|
||
| shouldUncurry :: Parser Bool | ||
| shouldUncurry = switch $ | ||
| short 'O' | ||
| <> long "optimize" | ||
| <> help "When given this option psc-bundle will apply an uncurry optimization" | ||
|
|
||
| noShouldUncurry :: Parser Bool | ||
| noShouldUncurry = switch $ | ||
| long "no-optimize" | ||
| <> help "When given this option psc-bundle will prevent the uncurry optimization" | ||
|
|
||
| -- | Make it go. | ||
| main :: IO () | ||
| main = do | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,14 +4,15 @@ A dead code elimination tool for PureScript-style CommonJS modules. This can be | |
|
|
||
| ## Usage | ||
|
|
||
| psc-bundle FILE (-m|--module ARG) [--main ARG] [--namespace ARG] | ||
| psc-bundle FILE (-m|--module ARG) [--main ARG] [--namespace ARG] [--optimize] | ||
|
|
||
| Options: | ||
|
|
||
| - The input .js file(s) | ||
| - Entry point module name(s) are specified with `-m` or `--module`. All code which is not a transitive dependency of an entry point module will be removed. | ||
| - The main module is (optionally) specified using `--main`. If specified, this will generate code to run the main method in the specified module. | ||
| - The browser namespace defaults to `PS`, and can be overridden with `--namespace`. | ||
| - The uncurry optimization option is off by default. It can be explicitly enabled with `-O` or `--optimize` and disabled with `--no-optimize`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now, it's on by default. |
||
|
|
||
| For example, to bundle the modules in the `output` directory, with main module `Main`: | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Typo; still says "Hardy Jones"