Skip to content

Commit

Permalink
dx: add a nice warning when this.load is not supported
Browse files Browse the repository at this point in the history
- so it doesn't just silently skip the type-only fix on Rollup versions <2.60.0
  • Loading branch information
agilgur5 committed Sep 18, 2022
1 parent f99272b commit dd18e4b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion dist/rollup-plugin-typescript2.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27931,6 +27931,7 @@ catch (e) {

const typescript = (options) => {
let watchMode = false;
let supportsThisLoad = false;
let generateRound = 0;
let rollupOptions;
let context;
Expand Down Expand Up @@ -28015,6 +28016,9 @@ const typescript = (options) => {
context.error(`Installed TypeScript version '${tsModule.version}' is outside of supported range '>=2.4.0'`);
if (!require$$3.satisfies(this.meta.rollupVersion, ">=1.26.3", { includePrerelease: true }))
context.error(`Installed Rollup version '${this.meta.rollupVersion}' is outside of supported range '>=1.26.3'`);
supportsThisLoad = require$$3.satisfies(this.meta.rollupVersion, ">=2.60.0", { includePrerelease: true }); // this.load is 2.60.0+ only (c.f. https://github.com/rollup/rollup/blob/master/CHANGELOG.md#2600)
if (!supportsThisLoad)
context.warn(() => `${safe.exports.yellow("You are using a Rollup version '<2.60.0'")}. This may result in type-only files being ignored.`);
context.info(`rollup-plugin-typescript2 version: 0.34.0`);
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${value.version}` : value, 4)}`);
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
Expand Down Expand Up @@ -28103,7 +28107,7 @@ const typescript = (options) => {
addDeclaration(id, result);
// handle all type-only imports by resolving + loading all of TS's references
// Rollup can't see these otherwise, because they are "emit-less" and produce no JS
if (result.references && require$$3.satisfies(this.meta.rollupVersion, ">=2.60.0", { includePrerelease: true })) { // this.load is 2.60.0+ only
if (result.references && supportsThisLoad) {
for (const ref of result.references) {
if (ref.endsWith(".d.ts"))
continue;
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.cjs.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/rollup-plugin-typescript2.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -27902,6 +27902,7 @@ catch (e) {

const typescript = (options) => {
let watchMode = false;
let supportsThisLoad = false;
let generateRound = 0;
let rollupOptions;
let context;
Expand Down Expand Up @@ -27986,6 +27987,9 @@ const typescript = (options) => {
context.error(`Installed TypeScript version '${tsModule.version}' is outside of supported range '>=2.4.0'`);
if (!satisfies(this.meta.rollupVersion, ">=1.26.3", { includePrerelease: true }))
context.error(`Installed Rollup version '${this.meta.rollupVersion}' is outside of supported range '>=1.26.3'`);
supportsThisLoad = satisfies(this.meta.rollupVersion, ">=2.60.0", { includePrerelease: true }); // this.load is 2.60.0+ only (c.f. https://github.com/rollup/rollup/blob/master/CHANGELOG.md#2600)
if (!supportsThisLoad)
context.warn(() => `${safe.exports.yellow("You are using a Rollup version '<2.60.0'")}. This may result in type-only files being ignored.`);
context.info(`rollup-plugin-typescript2 version: 0.34.0`);
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${value.version}` : value, 4)}`);
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
Expand Down Expand Up @@ -28074,7 +28078,7 @@ const typescript = (options) => {
addDeclaration(id, result);
// handle all type-only imports by resolving + loading all of TS's references
// Rollup can't see these otherwise, because they are "emit-less" and produce no JS
if (result.references && satisfies(this.meta.rollupVersion, ">=2.60.0", { includePrerelease: true })) { // this.load is 2.60.0+ only
if (result.references && supportsThisLoad) {
for (const ref of result.references) {
if (ref.endsWith(".d.ts"))
continue;
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.es.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export { RPT2Options }
const typescript: PluginImpl<RPT2Options> = (options) =>
{
let watchMode = false;
let supportsThisLoad = false;
let generateRound = 0;
let rollupOptions: InputOptions;
let context: RollupContext;
Expand Down Expand Up @@ -136,6 +137,10 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
if (!satisfies(this.meta.rollupVersion, "$ROLLUP_VERSION_RANGE", { includePrerelease: true }))
context.error(`Installed Rollup version '${this.meta.rollupVersion}' is outside of supported range '$ROLLUP_VERSION_RANGE'`);

supportsThisLoad = satisfies(this.meta.rollupVersion, ">=2.60.0", { includePrerelease : true }); // this.load is 2.60.0+ only (c.f. https://github.com/rollup/rollup/blob/master/CHANGELOG.md#2600)
if (!supportsThisLoad)
context.warn(() => `${yellow("You are using a Rollup version '<2.60.0'")}. This may result in type-only files being ignored.`);

context.info(`rollup-plugin-typescript2 version: $RPT2_VERSION`);
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${(value as typeof tsModule).version}` : value, 4)}`);
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
Expand Down Expand Up @@ -260,7 +265,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>

// handle all type-only imports by resolving + loading all of TS's references
// Rollup can't see these otherwise, because they are "emit-less" and produce no JS
if (result.references && satisfies(this.meta.rollupVersion, ">=2.60.0", { includePrerelease : true })) { // this.load is 2.60.0+ only
if (result.references && supportsThisLoad) {
for (const ref of result.references) {
if (ref.endsWith(".d.ts"))
continue;
Expand Down

0 comments on commit dd18e4b

Please sign in to comment.