Skip to content

Commit 7332077

Browse files
committed
- relaxing module overrides to allow for ESNext ezolenko#54
1 parent e583dee commit 7332077

16 files changed

+280
-187
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ export default {
2929

3030
The plugin inherits all compiler options and file lists from your `tsconfig.json` file. If your tsconfig has another name or another relative path from the root directory, see `tsconfigDefaults`, `tsconfig` and `tsconfigOverride` options below. This also allows for passing in different tsconfig files depending on your build target.
3131

32-
The following compiler options are forced though:
32+
#### Some compiler options are forced
3333

34-
* `module`: `es2015`
3534
* `noEmitHelpers`: false
3635
* `importHelpers`: true
3736
* `noResolve`: false
@@ -40,6 +39,10 @@ The following compiler options are forced though:
4039
* `declarationDir`: `process.cwd()` (*only if `useTsconfigDeclarationDir` is false in the plugin options*)
4140
* `moduleResolution`: `node` (*`classic` is [depreciated](https://www.typescriptlang.org/docs/handbook/module-resolution.html). It also breaks this plugin, see [#12](https://github.com/ezolenko/rollup-plugin-typescript2/issues/12) and [#14](https://github.com/ezolenko/rollup-plugin-typescript2/issues/14)*)
4241

42+
#### Some compiler options have more than one compatible value.
43+
44+
* `module`: defaults to `ES2015`, other valid value is `ESNext` (required for dynamic imports, see [#54](https://github.com/ezolenko/rollup-plugin-typescript2/issues/54)).
45+
4346
### Plugin options
4447

4548
* `tsconfigDefaults`: `{}`

dist/check-tsconfig.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import * as tsTypes from "typescript";
2+
export declare function checkTsConfig(parsedConfig: tsTypes.ParsedCommandLine): void;

dist/get-option-defaults.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export declare function getOptionsDefaults(): {
2+
compilerOptions: {
3+
module: string;
4+
};
5+
};
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as tsTypes from "typescript";
2-
import { IContext } from "./context";
3-
import { IOptions } from "./ioptions";
4-
export declare function parseTsConfig(context: IContext, pluginOptions: IOptions): tsTypes.ParsedCommandLine;
1+
import * as tsTypes from "typescript";
2+
import { IContext } from "./context";
3+
import { IOptions } from "./ioptions";
4+
export declare function parseTsConfig(context: IContext, pluginOptions: IOptions): tsTypes.ParsedCommandLine;

dist/rollup-plugin-typescript2.cjs.js

+58-28
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
2323
See the Apache Version 2.0 License for specific language governing permissions
2424
and limitations under the License.
2525
***************************************************************************** */
26-
/* global Reflect, Promise */
27-
28-
2926

3027
var __assign = Object.assign || function __assign(t) {
3128
for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -41,21 +38,11 @@ function commonjsRequire () {
4138
throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
4239
}
4340

44-
45-
4641
function createCommonjsModule(fn, module) {
4742
return module = { exports: {} }, fn(module, module.exports), module.exports;
4843
}
4944

5045
var lodash = createCommonjsModule(function (module, exports) {
51-
/**
52-
* @license
53-
* Lodash <https://lodash.com/>
54-
* Copyright JS Foundation and other contributors <https://js.foundation/>
55-
* Released under MIT license <https://lodash.com/license>
56-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
57-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
58-
*/
5946
(function() {
6047

6148
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
@@ -17133,7 +17120,6 @@ var lodash = createCommonjsModule(function (module, exports) {
1713317120
}
1713417121
}.call(commonjsGlobal));
1713517122
});
17136-
1713717123
var lodash_1 = lodash.get;
1713817124
var lodash_2 = lodash.each;
1713917125
var lodash_3 = lodash.isEqual;
@@ -17314,25 +17300,25 @@ var LanguageServiceHost = /** @class */ (function () {
1731417300

1731517301
/* global window */
1731617302

17317-
var lodash$2;
17303+
var lodash$1;
1731817304

1731917305
if (typeof commonjsRequire === "function") {
1732017306
try {
17321-
lodash$2 = lodash;
17307+
lodash$1 = lodash;
1732217308
} catch (e) {}
1732317309
}
1732417310

17325-
if (!lodash$2) {
17326-
lodash$2 = window._;
17311+
if (!lodash$1) {
17312+
lodash$1 = window._;
1732717313
}
1732817314

17329-
var lodash_1$1 = lodash$2;
17315+
var lodash_1$1 = lodash$1;
1733017316

1733117317
var graph = Graph;
1733217318

17333-
var DEFAULT_EDGE_NAME = "\x00";
17334-
var GRAPH_NODE = "\x00";
17335-
var EDGE_KEY_DELIM = "\x01";
17319+
var DEFAULT_EDGE_NAME = "\x00",
17320+
GRAPH_NODE = "\x00",
17321+
EDGE_KEY_DELIM = "\x01";
1733617322

1733717323
// Implementation notes:
1733817324
//
@@ -18470,11 +18456,36 @@ var graphlib = {
1847018456
alg: alg,
1847118457
version: lib.version
1847218458
};
18473-
1847418459
var graphlib_1 = graphlib.Graph;
1847518460
var graphlib_3 = graphlib.alg;
1847618461

1847718462
var objectHash_1 = createCommonjsModule(function (module, exports) {
18463+
18464+
18465+
18466+
/**
18467+
* Exported function
18468+
*
18469+
* Options:
18470+
*
18471+
* - `algorithm` hash algo to be used by this instance: *'sha1', 'md5'
18472+
* - `excludeValues` {true|*false} hash object keys, values ignored
18473+
* - `encoding` hash encoding, supports 'buffer', '*hex', 'binary', 'base64'
18474+
* - `ignoreUnknown` {true|*false} ignore unknown object types
18475+
* - `replacer` optional function that replaces values before hashing
18476+
* - `respectFunctionProperties` {*true|false} consider function properties when hashing
18477+
* - `respectFunctionNames` {*true|false} consider 'name' property of functions for hashing
18478+
* - `respectType` {*true|false} Respect special properties (prototype, constructor)
18479+
* when hashing to distinguish between types
18480+
* - `unorderedArrays` {true|*false} Sort all arrays before hashing
18481+
* - `unorderedSets` {*true|false} Sort `Set` and `Map` instances before hashing
18482+
* * = default
18483+
*
18484+
* @param {object} object value to hash
18485+
* @param {object} options hashing options
18486+
* @return {string} hash value
18487+
* @api public
18488+
*/
1847818489
exports = module.exports = objectHash;
1847918490

1848018491
function objectHash(object, options){
@@ -18886,7 +18897,6 @@ function PassThrough() {
1888618897
};
1888718898
}
1888818899
});
18889-
1889018900
var objectHash_2 = objectHash_1.sha1;
1889118901
var objectHash_3 = objectHash_1.keys;
1889218902
var objectHash_4 = objectHash_1.MD5;
@@ -19504,7 +19514,6 @@ var safe = createCommonjsModule(function (module) {
1950419514

1950519515
module['exports'] = colors_1;
1950619516
});
19507-
1950819517
var safe_1 = safe.green;
1950919518
var safe_2 = safe.white;
1951019519
var safe_3 = safe.red;
@@ -19731,7 +19740,6 @@ function printDiagnostics(context, diagnostics, pretty) {
1973119740
function getOptionsOverrides(_a, tsConfigJson) {
1973219741
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir;
1973319742
var overrides = {
19734-
module: tsModule.ModuleKind.ES2015,
1973519743
noEmitHelpers: false,
1973619744
importHelpers: true,
1973719745
noResolve: false,
@@ -19747,6 +19755,27 @@ function getOptionsOverrides(_a, tsConfigJson) {
1974719755
return overrides;
1974819756
}
1974919757

19758+
function checkTsConfig(parsedConfig) {
19759+
var module = parsedConfig.options.module;
19760+
switch (module) {
19761+
case tsModule.ModuleKind.ES2015:
19762+
case tsModule.ModuleKind.ESNext:
19763+
break;
19764+
case undefined:
19765+
throw new Error("Incompatible tsconfig option. Missing module option. This is incompatible with rollup, please use 'module: \"ES2015\"' or 'module: \"ESNext\"'.");
19766+
default:
19767+
throw new Error("Incompatible tsconfig option. Module resolves to '" + tsModule.ModuleKind[module] + "'. This is incompatible with rollup, please use 'module: \"ES2015\"' or 'module: \"ESNext\"'.");
19768+
}
19769+
}
19770+
19771+
function getOptionsDefaults() {
19772+
return {
19773+
compilerOptions: {
19774+
module: "ES2015",
19775+
},
19776+
};
19777+
}
19778+
1975019779
function parseTsConfig(context, pluginOptions) {
1975119780
var fileName = tsModule.findConfigFile(process.cwd(), tsModule.sys.fileExists, pluginOptions.tsconfig);
1975219781
// if the value was provided, but no file, fail hard
@@ -19769,9 +19798,10 @@ function parseTsConfig(context, pluginOptions) {
1976919798
configFileName = fileName;
1977019799
}
1977119800
var mergedConfig = {};
19772-
lodash_14(mergedConfig, pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
19801+
lodash_14(mergedConfig, getOptionsDefaults(), pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
1977319802
var compilerOptionsOverride = getOptionsOverrides(pluginOptions, mergedConfig);
1977419803
var parsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, compilerOptionsOverride, configFileName);
19804+
checkTsConfig(parsedTsConfig);
1977519805
context.debug("built-in options overrides: " + JSON.stringify(compilerOptionsOverride, undefined, 4));
1977619806
context.debug("parsed tsconfig: " + JSON.stringify(parsedTsConfig, undefined, 4));
1977719807
return parsedTsConfig;
@@ -19833,7 +19863,7 @@ function typescript(options) {
1983319863
rollupOptions = __assign({}, config);
1983419864
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
1983519865
context.info("typescript version: " + tsModule.version);
19836-
context.info("rollup-plugin-typescript2 version: 0.11.1");
19866+
context.info("rollup-plugin-typescript2 version: 0.12.0");
1983719867
context.debug(function () { return "plugin options:\n" + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4); });
1983819868
context.debug(function () { return "rollup config:\n" + JSON.stringify(rollupOptions, undefined, 4); });
1983919869
watchMode = process.env.ROLLUP_WATCH === "true";

dist/rollup-plugin-typescript2.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)