From 23ffe894f0fad022f3a00a938ac62aa12f8e5f43 Mon Sep 17 00:00:00 2001 From: Lukas Taegert Date: Fri, 7 Sep 2018 17:25:57 +0200 Subject: [PATCH] Fix how tslib is found --- package-lock.json | 13 +++++++++++++ package.json | 1 + rollup.config.js | 1 + src/index.js | 7 +++---- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 605cebb..df428d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -998,6 +998,11 @@ "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", "dev": true }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -1079,6 +1084,14 @@ "resolve-from": "1.0.1" } }, + "resolve": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", + "requires": { + "path-parse": "1.0.6" + } + }, "resolve-from": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", diff --git a/package.json b/package.json index afd4f2c..fef999b 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "dependencies": { "compare-versions": "2.0.1", "object-assign": "^4.0.1", + "resolve": "^1.8.1", "rollup-pluginutils": "^1.3.1", "tippex": "^2.1.1", "tslib": ">=1.9.0", diff --git a/rollup.config.js b/rollup.config.js index 661d839..c562189 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -9,6 +9,7 @@ export default { 'path', 'fs', 'object-assign', + 'resolve', 'rollup-pluginutils', 'tippex', 'typescript' diff --git a/src/index.js b/src/index.js index 3d87f7f..8e4ff76 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,9 @@ import * as ts from 'typescript'; import { createFilter } from 'rollup-pluginutils'; -import * as path from 'path'; import * as fs from 'fs'; import assign from 'object-assign'; import compareVersions from 'compare-versions'; +import resolveId from 'resolve'; import { endsWith } from './string'; import { getDefaultOptions, compilerOptionsFromTsConfig, adjustCompilerOptions } from './options.js'; @@ -19,9 +19,8 @@ interface Options { } */ -// The injected id for helpers. Intentially invalid to prevent helpers being included in source maps. -const helpersId = 'tslib'; -const helpersSource = fs.readFileSync( path.resolve( __dirname, '../node_modules/tslib/tslib.es6.js' ), 'utf-8' ); +const helpersId = '\0tslib'; +const helpersSource = fs.readFileSync(resolveId.sync('tslib/tslib.es6.js', { basedir: __dirname }), 'utf-8' ); export default function typescript ( options ) { options = assign( {}, options || {} );