-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
130 lines (126 loc) · 4.25 KB
/
babel.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
module.exports = {
presets: [
[
"@babel/preset-env",
{
useBuiltIns: "usage",
corejs: {
version: "3.6",
},
targets: {
node: 10,
},
modules: "commonjs",
},
],
],
plugins: [
[
"@babel/plugin-transform-typescript",
{
isTSX: true,
allExtensions: true,
allowNamespaces: true,
allowDeclareFields: true,
},
],
["@babel/plugin-proposal-decorators", { legacy: true }],
["@babel/plugin-proposal-class-properties", { loose: false }],
["@babel/plugin-proposal-private-methods", { loose: false }],
...getRxjsTransforms(),
],
ignore: ["**/*.d.ts"],
only: [
function(filepath) {
const r = filepath.startsWith(__dirname) && /[\/\\]node_modules[\/\\]/.test(filepath) == false;
return r;
},
],
};
function getRxjsTransforms() {
const rxjs = {
Observable: "internal/Observable",
ConnectableObservable: "internal/observable/ConnectableObservable",
GroupedObservable: "internal/operators/groupBy",
observable: "internal/symbol/observable",
Subject: "internal/Subject",
BehaviorSubject: "internal/BehaviorSubject",
ReplaySubject: "internal/ReplaySubject",
AsyncSubject: "internal/AsyncSubject",
asapScheduler: "internal/scheduler/asap",
asyncScheduler: "internal/scheduler/async",
queueScheduler: "internal/scheduler/queue",
animationFrameScheduler: "internal/scheduler/animationFrame",
VirtualTimeScheduler: "internal/scheduler/VirtualTimeScheduler",
Scheduler: "internal/Scheduler",
Subscription: "internal/Subscription",
Subscriber: "internal/Subscriber",
Notification: "internal/Notification",
pipe: "internal/util/pipe",
noop: "internal/util/noop",
identity: "internal/util/identity",
isObservable: "internal/util/isObservable",
ArgumentOutOfRangeError: "internal/util/ArgumentOutOfRangeError",
EmptyError: "internal/util/EmptyError",
ObjectUnsubscribedError: "internal/util/ObjectUnsubscribedError",
UnsubscriptionError: "internal/util/UnsubscriptionError",
TimeoutError: "internal/util/TimeoutError",
bindCallback: "internal/observable/bindCallback",
bindNodeCallback: "internal/observable/bindNodeCallback",
combineLatest: "internal/observable/combineLatest",
concat: "internal/observable/concat",
defer: "internal/observable/defer",
empty: "internal/observable/empty",
forkJoin: "internal/observable/forkJoin",
from: "internal/observable/from",
fromEvent: "internal/observable/fromEvent",
fromEventPattern: "internal/observable/fromEventPattern",
generate: "internal/observable/generate",
iif: "internal/observable/iif",
interval: "internal/observable/interval",
merge: "internal/observable/merge",
never: "internal/observable/never",
of: "internal/observable/of",
onErrorResumeNext: "internal/observable/onErrorResumeNext",
pairs: "internal/observable/pairs",
race: "internal/observable/race",
range: "internal/observable/range",
throwError: "internal/observable/throwError",
timer: "internal/observable/timer",
using: "internal/observable/using",
zip: "internal/observable/zip",
EMPTY: "internal/observable/empty",
NEVER: "internal/observable/never",
config: "internal/config",
};
const rxjsAjax = {
ajax: "internal/observable/dom/ajax",
AjaxRequest: "internal/observable/dom/AjaxObservable",
AjaxResponse: "internal/observable/dom/AjaxObservable",
AjaxError: "internal/observable/dom/AjaxObservable",
AjaxTimeoutError: "internal/observable/dom/AjaxObservable",
};
const transformImports = [
[
"transform-imports",
{
rxjs: {
transform: (importName, matches) => `rxjs/${rxjs[importName]}`,
preventFullImport: true,
skipDefaultConversion: true,
},
"rxjs/ajax": {
transform: (importName, matches) => `rxjs/${rxjsAjax[importName]}`,
preventFullImport: true,
skipDefaultConversion: true,
},
"rxjs/operators": {
transform: "rxjs/internal/operators/${member}",
preventFullImport: true,
skipDefaultConversion: true,
},
},
],
];
return transformImports;
}