You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clean: remove ConsoleContext entirely by using buildStart (ezolenko#414)
- the only reason that `ConsoleContext` was still used was because the `options` hook doesn't support certain context functions like `this.error` / `this.warn` etc
- but `buildStart` does! so we can just move pretty much everything into `buildStart` instead
- didn't move setting `rollupOptions` because that value gets hashed and the value in `buildStart` is different, as it is after all plugins' `options` hooks have ran
- this way we don't need `ConsoleContext` what-so-ever and so can remove it entirely!
- as well as `IContext`, its tests, etc
- use `this.error` instead of `throw`ing errors in `parse-tsconfig` as it exists now
- couldn't in the `options` hook, can in `buildStart`
- this also ensure we don't have all the `rpt2: ` prefixes ever missing again
- c.f. ff88951, 0628482
- refactor `parse-tsconfig.spec` to account for this change
- c.f. Rollup hooks docs: https://rollupjs.org/guide/en/#options, https://rollupjs.org/guide/en/#buildstart
})).toThrow("Incompatible tsconfig option. Module resolves to 'None'. This is incompatible with Rollup, please use");
27
+
});
28
+
29
+
expect(context.error).toHaveBeenLastCalledWith(expect.stringContaining("Incompatible tsconfig option. Module resolves to 'None'. This is incompatible with Rollup, please use"));
22
30
});
23
31
24
32
test("parseTsConfig - tsconfig errors",()=>{
25
33
constcontext=makeContext();
26
34
27
-
// should not throw when the tsconfig is buggy, but should still print an error (below)
28
-
expect(()=>parseTsConfig(context,{
35
+
parseTsConfig(context,{
29
36
...defaultOpts,
30
37
tsconfigOverride: {
31
38
include: "should-be-an-array",
32
39
},
33
-
})).not.toThrow();
40
+
});
41
+
34
42
expect(context.error).toHaveBeenLastCalledWith(expect.stringContaining("Compiler option 'include' requires a value of type Array"));
35
43
});
36
44
37
45
test("parseTsConfig - failed to open",()=>{
38
-
expect(()=>parseTsConfig(makeContext(),{
46
+
constcontext=makeContext();
47
+
constnonExistentTsConfig="non-existent-tsconfig";
48
+
49
+
parseTsConfig(context,{
39
50
...defaultOpts,
40
-
tsconfig: "non-existent-tsconfig",
41
-
})).toThrow("rpt2: failed to open 'non-existent-tsconfig'");
51
+
tsconfig: nonExistentTsConfig,
52
+
})
53
+
54
+
expect(context.error).toHaveBeenLastCalledWith(expect.stringContaining(`failed to open '${nonExistentTsConfig}`));
42
55
});
43
56
44
57
test("parseTsConfig - failed to parse",()=>{
58
+
constcontext=makeContext();
45
59
constnotTsConfigPath=local("fixtures/options.ts");// a TS file should fail to parse
46
60
47
-
expect(()=>parseTsConfig(makeContext(),{
61
+
parseTsConfig(context,{
48
62
...defaultOpts,
49
63
tsconfig: notTsConfigPath,
50
-
})).toThrow(`rpt2: failed to parse '${notTsConfigPath}'`);
64
+
})
65
+
66
+
expect(context.error).toHaveBeenLastCalledWith(expect.stringContaining(`failed to parse '${notTsConfigPath}'`));
watchMode=process.env.ROLLUP_WATCH==="true"||!!this.meta.watchMode;// meta.watchMode was added in 2.14.0 to capture watch via Rollup API (i.e. no env var) (c.f. https://github.com/rollup/rollup/blob/master/CHANGELOG.md#2140)
// always checking on fatal errors, even if options.check is set to false
226
-
typecheckFile(id,snapshot,contextWrapper);
227
+
typecheckFile(id,snapshot,context);
227
228
// since no output was generated, aborting compilation
228
229
this.error(red(`Emit skipped for '${id}'. See https://github.com/microsoft/TypeScript/issues/49790 for potential reasons why this may occur`));
thrownewError(`rpt2: Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with Rollup, please use 'module: "ES2015"', 'module: "ES2020"', or 'module: "ESNext"'.`);
49
+
context.error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with Rollup, please use 'module: "ES2015"', 'module: "ES2020"', or 'module: "ESNext"'.`);
0 commit comments