This repository was archived by the owner on Jun 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
[Fixes #12] Add Browserify to build #18
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 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 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 |
---|---|---|
|
@@ -2,11 +2,11 @@ | |
|
||
"use strict"; | ||
|
||
interface ExtendedTextStyle extends PIXI.TextStyleOptions { | ||
export interface ExtendedTextStyle extends PIXI.TextStyleOptions { | ||
valign?: "top" | "middle" | "bottom"; | ||
} | ||
|
||
interface TextStyleSet { | ||
export interface TextStyleSet { | ||
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. Is it necessary/useful to export the interfaces? 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. Yes, it's required - you can't export the |
||
[key: string]: ExtendedTextStyle; | ||
} | ||
|
||
|
@@ -24,7 +24,7 @@ interface TextData { | |
fontProperties: FontProperties; | ||
} | ||
|
||
class MultiStyleText extends PIXI.Text { | ||
export class MultiStyleText extends PIXI.Text { | ||
private textStyles: TextStyleSet; | ||
|
||
constructor(text: string, styles: TextStyleSet) { | ||
|
This file contains 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
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.
I thought
tsc
was already compiling down to basic JS. Could you explain why browserify is required here?Also, I'd like to find a way to remove the new wrapped module to remove the duplication
MultiStyleText.MultiStyleText
when the file is injected in a script tag instead of using a commonjs require/import for example.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.
The point of Browserify here is to export the module for CommonJS and AMD if either of those are being used, and otherwise defaulting to a global export. This is similar to how Pixi itself functions (and they also use Browserify to build). I was originally hoping we could get away with using TS's
umd
module mode, which handles both CommonJS and AMD properly, but it doesn't default to exposing the module globally if neither is found.I'd also like to remove the "double wrapping" problem if possible, but I couldn't find a way to do so. (In particular, I would've expected that
export default class MultiStyleText
would do the trick, but that instead exports the class toMultiStyleText.default
.)I'll keep looking into it.
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 found a solution. I don't love it (it's kind of a hack), but it works. See TypeStrong/tsify#105.