ts-loader
Advanced tools
Comparing version 0.3.1 to 0.3.2
# Changelog | ||
## v0.3.2 | ||
- Add support for manually adding files (#6) | ||
- Add paths to source maps (#8) | ||
## v0.3.1 | ||
@@ -4,0 +9,0 @@ |
35
index.js
@@ -18,4 +18,16 @@ ///<reference path="node_modules/typescript/bin/typescript.d.ts" /> | ||
var compiler = require(options.compiler); | ||
if (Object.prototype.hasOwnProperty.call(instances, options.instance)) | ||
return instances[options.instance]; | ||
var files = {}; | ||
if (Object.prototype.hasOwnProperty.call(instances, options.instance)) { | ||
var instance = instances[options.instance]; | ||
files = instance.files; | ||
options.additionalFiles.forEach(function (filePath) { | ||
if (!Object.prototype.hasOwnProperty.call(options.additionalFiles, filePath)) { | ||
files[filePath] = { | ||
text: fs.readFileSync(filePath, 'utf-8'), | ||
version: 0 | ||
}; | ||
} | ||
}); | ||
return instance; | ||
} | ||
var target; | ||
@@ -37,8 +49,9 @@ switch (options.target) { | ||
}; | ||
var files = {}; | ||
var libPath = path.join(path.dirname(require.resolve('typescript')), 'lib.d.ts'); | ||
files[libPath] = { | ||
text: fs.readFileSync(libPath, 'utf-8'), | ||
version: 0 | ||
}; | ||
options.additionalFiles.push(path.join(path.dirname(require.resolve('typescript')), 'lib.d.ts')); | ||
options.additionalFiles.forEach(function (filePath) { | ||
files[filePath] = { | ||
text: fs.readFileSync(filePath, 'utf-8'), | ||
version: 0 | ||
}; | ||
}); | ||
var servicesHost = { | ||
@@ -82,4 +95,6 @@ getScriptFileNames: function () { return Object.keys(files); }, | ||
compiler: 'typescript', | ||
sourceMap: false | ||
sourceMap: false, | ||
additionalFiles: [] | ||
}, options); | ||
options.additionalFiles = options.additionalFiles.map(function (filePath) { return path.resolve(_this.context, filePath); }); | ||
var instance = ensureTypeScriptInstance(options); | ||
@@ -115,2 +130,4 @@ if (!Object.prototype.hasOwnProperty.call(instance.files, filePath)) { | ||
sourceMap = JSON.parse(output.outputFiles[0].text); | ||
sourceMap.sources = [loaderUtils.getRemainingRequest(this)]; | ||
sourceMap.file = loaderUtils.getCurrentRequest(this); | ||
sourceMap.sourcesContent = [contents]; | ||
@@ -117,0 +134,0 @@ contents = output.outputFiles[1].text; |
{ | ||
"name": "ts-loader", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "TypeScript loader for webpack", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -59,2 +59,9 @@ # TypeScript loader for webpack | ||
##### additionalFiles *(array of string) (default=[])* | ||
Allows additional files to be manually passed to the TypeScript compiler. | ||
For example, if you want to make a declaration file available without | ||
actually referencing it in code with a `/// <references />` tag. Should | ||
consist of rooted paths. | ||
##### instance *(string)* | ||
@@ -66,25 +73,2 @@ | ||
### Declaration files | ||
All declaration files should be resolvable from the entry file. The easiest way | ||
to do this is to create a `_references.d.ts` file which contains references to | ||
all of your declaration files. Then reference `_references.d.ts` from your | ||
entry file. | ||
_references.d.ts | ||
``` | ||
///<reference path="path/to/declaration.d.ts" /> | ||
///<reference path="path/to/another/declaration.d.ts" /> | ||
``` | ||
app.ts | ||
``` | ||
///<reference path="path/to/_references.d.ts" /> | ||
import MyClass = require('./MyClass'); | ||
... | ||
``` | ||
### Loading other resources and code splitting | ||
@@ -91,0 +75,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12870
138
131