Skip to content

Commit e07471a

Browse files
committed
Include src folder in tsconfig defaults
1 parent 711beaf commit e07471a

File tree

3 files changed

+55
-49
lines changed

3 files changed

+55
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ The Rollpkg default is to compile your code to `ES2018` which is supported by al
283283

284284
To control how your code is compiled and what JS APIs are available at runtime use the [`target`](https://www.typescriptlang.org/tsconfig#target) and [`lib`](https://www.typescriptlang.org/tsconfig#lib) options in your `tsconfig`. The `target` option specifies the ECMAScript version that your code is compiled to (`ES5`, `ES2018`, etc). The `lib` option specifies the JS APIs that will be available at runtime, which is needed for using JS APIs that can't be compiled to the specified `target`. For example, `array.includes` and the `Promise` API cannot be compiled to `ES5` but you may find it necessary to use them in your code (note that all JS APIs in your code will need to be available in the browser, either supported natively or provided by a polyfill).
285285

286-
For example, let's say your `target` is `ES5` and need to use the `Promise` API, your `tsconfig.json` would look like this:
286+
For example, let's say your `target` is `ES5` and you need to use the `Promise` API, your `tsconfig.json` would look like this:
287287

288288
> Note that when using the `lib` option you need to specify _all_ available JS APIs, including the base `ES5` APIs and `DOM` APIs.
289289

src/__tests__/__snapshots__/createRollupConfig.test.ts.snap

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ Array [
1919
"target": "ES2018",
2020
"types": Array [],
2121
},
22-
},
23-
"tsconfigOverride": Object {
24-
"compilerOptions": Object {
25-
"module": "ESNext",
26-
"sourceMap": true,
27-
},
2822
"exclude": Array [
2923
"**/__tests__",
3024
"**/__mocks__",
@@ -34,9 +28,16 @@ Array [
3428
"**/*.mock.*",
3529
],
3630
"include": Array [
31+
"src",
3732
"./node_modules/rollpkg/configs/types",
3833
],
3934
},
35+
"tsconfigOverride": Object {
36+
"compilerOptions": Object {
37+
"module": "ESNext",
38+
"sourceMap": true,
39+
},
40+
},
4041
},
4142
"name": "rollup-plugin-typescript2",
4243
},
@@ -69,12 +70,6 @@ Array [
6970
"target": "ES2018",
7071
"types": Array [],
7172
},
72-
},
73-
"tsconfigOverride": Object {
74-
"compilerOptions": Object {
75-
"module": "ESNext",
76-
"sourceMap": true,
77-
},
7873
"exclude": Array [
7974
"**/__tests__",
8075
"**/__mocks__",
@@ -84,9 +79,16 @@ Array [
8479
"**/*.mock.*",
8580
],
8681
"include": Array [
82+
"src",
8783
"./node_modules/rollpkg/configs/types",
8884
],
8985
},
86+
"tsconfigOverride": Object {
87+
"compilerOptions": Object {
88+
"module": "ESNext",
89+
"sourceMap": true,
90+
},
91+
},
9092
},
9193
"name": "rollup-plugin-typescript2",
9294
},
@@ -119,12 +121,6 @@ Array [
119121
"target": "ES2018",
120122
"types": Array [],
121123
},
122-
},
123-
"tsconfigOverride": Object {
124-
"compilerOptions": Object {
125-
"module": "ESNext",
126-
"sourceMap": true,
127-
},
128124
"exclude": Array [
129125
"**/__tests__",
130126
"**/__mocks__",
@@ -134,9 +130,16 @@ Array [
134130
"**/*.mock.*",
135131
],
136132
"include": Array [
133+
"src",
137134
"./node_modules/rollpkg/configs/types",
138135
],
139136
},
137+
"tsconfigOverride": Object {
138+
"compilerOptions": Object {
139+
"module": "ESNext",
140+
"sourceMap": true,
141+
},
142+
},
140143
},
141144
"name": "rollup-plugin-typescript2",
142145
},
@@ -175,12 +178,6 @@ Array [
175178
"target": "ES2018",
176179
"types": Array [],
177180
},
178-
},
179-
"tsconfigOverride": Object {
180-
"compilerOptions": Object {
181-
"module": "ESNext",
182-
"sourceMap": true,
183-
},
184181
"exclude": Array [
185182
"**/__tests__",
186183
"**/__mocks__",
@@ -190,9 +187,16 @@ Array [
190187
"**/*.mock.*",
191188
],
192189
"include": Array [
190+
"src",
193191
"./node_modules/rollpkg/configs/types",
194192
],
195193
},
194+
"tsconfigOverride": Object {
195+
"compilerOptions": Object {
196+
"module": "ESNext",
197+
"sourceMap": true,
198+
},
199+
},
196200
},
197201
"name": "rollup-plugin-typescript2",
198202
},
@@ -246,12 +250,6 @@ Array [
246250
"target": "ES2018",
247251
"types": Array [],
248252
},
249-
},
250-
"tsconfigOverride": Object {
251-
"compilerOptions": Object {
252-
"module": "ESNext",
253-
"sourceMap": true,
254-
},
255253
"exclude": Array [
256254
"**/__tests__",
257255
"**/__mocks__",
@@ -261,9 +259,16 @@ Array [
261259
"**/*.mock.*",
262260
],
263261
"include": Array [
262+
"src",
264263
"./node_modules/rollpkg/configs/types",
265264
],
266265
},
266+
"tsconfigOverride": Object {
267+
"compilerOptions": Object {
268+
"module": "ESNext",
269+
"sourceMap": true,
270+
},
271+
},
267272
},
268273
"name": "rollup-plugin-typescript2",
269274
},
@@ -302,12 +307,6 @@ Array [
302307
"target": "ES2018",
303308
"types": Array [],
304309
},
305-
},
306-
"tsconfigOverride": Object {
307-
"compilerOptions": Object {
308-
"module": "ESNext",
309-
"sourceMap": true,
310-
},
311310
"exclude": Array [
312311
"**/__tests__",
313312
"**/__mocks__",
@@ -317,9 +316,16 @@ Array [
317316
"**/*.mock.*",
318317
],
319318
"include": Array [
319+
"src",
320320
"./node_modules/rollpkg/configs/types",
321321
],
322322
},
323+
"tsconfigOverride": Object {
324+
"compilerOptions": Object {
325+
"module": "ESNext",
326+
"sourceMap": true,
327+
},
328+
},
323329
},
324330
"name": "rollup-plugin-typescript2",
325331
},

src/rollupBuilds.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ export const createRollupConfig: CreateRollupConfig = ({
7676
// this doesn't prevent other non-build files like *.mock.ts from being outside the src directory
7777
rootDir: './src',
7878
},
79+
// include rollpkg types that stub process.env.NODE_ENV and __DEV__
80+
// so they can be used without polluting the global type space with all node types etc
81+
include: ['src', './node_modules/rollpkg/configs/types'],
82+
// exclude tests, mocks and snapshots
83+
exclude: [
84+
'**/__tests__',
85+
'**/__mocks__',
86+
'**/__snapshots__',
87+
'**/*.test.*',
88+
'**/*.spec.*',
89+
'**/*.mock.*',
90+
],
7991
},
8092
tsconfig: tsconfigPath,
8193
tsconfigOverride: {
@@ -88,18 +100,6 @@ export const createRollupConfig: CreateRollupConfig = ({
88100
// as rollup has it's own inline sources option, "sourcemapExcludeSources" which defaults to false
89101
sourceMap: true,
90102
},
91-
// include rollpkg types that stub process.env.NODE_ENV and __DEV__
92-
// so they can be used without polluting the global type space with all node types etc
93-
include: ['./node_modules/rollpkg/configs/types'],
94-
// exclude tests, mocks and snapshots
95-
exclude: [
96-
'**/__tests__',
97-
'**/__mocks__',
98-
'**/__snapshots__',
99-
'**/*.test.*',
100-
'**/*.spec.*',
101-
'**/*.mock.*',
102-
],
103103
},
104104
include: ['**/*.ts+(|x)', '**/*.js+(|x)'],
105105
}),

0 commit comments

Comments
 (0)