-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fixed single outFile generation (#1) - All input files now point to the same output file - Added `AllowJS` compiler flag, as this is useful for projects using outFile - Added `typingsFile` option to allow typings files to be written for older JS code being included in the single file output * Added scripted test for single-outfile fixes
- Loading branch information
1 parent
da4a89a
commit 2500372
Showing
13 changed files
with
194 additions
and
27 deletions.
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
28 changes: 28 additions & 0 deletions
28
src/sbt-test/sbt-typescript-plugin/single-outfile/build.sbt
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import java.nio.file.Files | ||
|
||
import com.arpnetworking.sbt.typescript.Import.TypescriptKeys._ | ||
import sbt.complete.DefaultParsers._ | ||
|
||
lazy val root = (project in file(".")).enablePlugins(SbtWeb).settings( | ||
JsEngineKeys.engineType := JsEngineKeys.EngineType.Node, | ||
outFile := "app.js", // Create a single output file | ||
moduleKind := "AMD", | ||
sourceMap := true, | ||
sourceRoot := "/assets/", // Map the root folder to a URL on the server | ||
allowJS := true, // Allow "legacy" JS files to be included and compiled into the single output file | ||
typingsFile := Some(file("typings/index.d.ts")) // Include the typings root file | ||
) | ||
|
||
lazy val assertMatches = inputKey[Unit]("") | ||
|
||
assertMatches := { | ||
spaceDelimited("<arg>").parsed.map(file) match { | ||
case Seq(actual, expected) ⇒ | ||
assert(actual.exists, s"Generated file ${actual.getName} does not exist") | ||
assert(expected.exists, s"Expected file ${expected.getName} does not exist") | ||
assert(readAllText(actual) == readAllText(expected), s"Generated file ${actual.getName} does not match expected") | ||
} | ||
} | ||
|
||
def readAllText(file: File) = new String(Files.readAllBytes(file.toPath), "UTF-8") | ||
|
20 changes: 20 additions & 0 deletions
20
src/sbt-test/sbt-typescript-plugin/single-outfile/expected/app.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
src/sbt-test/sbt-typescript-plugin/single-outfile/expected/app.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/sbt-test/sbt-typescript-plugin/single-outfile/project/build.properties
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Copyright 2014 Groupon.com | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
sbt.version=0.13.5 |
25 changes: 25 additions & 0 deletions
25
src/sbt-test/sbt-typescript-plugin/single-outfile/project/plugins.sbt
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// Copyright 2014 Groupon.com | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
|
||
addSbtPlugin("com.arpnetworking" % "sbt-typescript" % sys.props("project.version")) | ||
|
||
resolvers ++= Seq( | ||
Resolver.mavenLocal, | ||
Resolver.url("sbt snapshot plugins", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns), | ||
Resolver.sonatypeRepo("snapshots"), | ||
"Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/" | ||
) |
5 changes: 5 additions & 0 deletions
5
src/sbt-test/sbt-typescript-plugin/single-outfile/src/main/assets/javascripts/main.ts
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {upperCase} from './util/string'; // TS file in another folder (testing source maps) | ||
import {log} from './util/logger'; // Legacy JS file | ||
|
||
// Legacy is a "global" object which typescript will complain about without the typings file | ||
log(Legacy.someFunc(upperCase("Hello World"))); |
3 changes: 3 additions & 0 deletions
3
src/sbt-test/sbt-typescript-plugin/single-outfile/src/main/assets/javascripts/util/logger.js
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function log(str) { | ||
console.log(str); | ||
} |
3 changes: 3 additions & 0 deletions
3
src/sbt-test/sbt-typescript-plugin/single-outfile/src/main/assets/javascripts/util/string.ts
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function upperCase(str: string): string { | ||
return str.toUpperCase(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Compile a typescript file | ||
|
||
> assets | ||
> assertMatches target/web/public/main/app.js expected/app.js | ||
> assertMatches target/web/public/main/app.js.map expected/app.js.map | ||
|
6 changes: 6 additions & 0 deletions
6
src/sbt-test/sbt-typescript-plugin/single-outfile/typings/index.d.ts
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
declare namespace __LegacyGlobal { | ||
function someFunc(str: string): string; | ||
} | ||
|
||
import Legacy = __LegacyGlobal; |