@@ -19,6 +19,7 @@ import { extname, join as pathJoin } from 'path';
19
19
const PACKAGES = [
20
20
'babel-plugin-transform-class-properties' ,
21
21
'babel-plugin-transform-private-methods' ,
22
+ 'babel-plugin-transform-private-property-in-object' ,
22
23
'babel-plugin-transform-logical-assignment-operators' ,
23
24
] ;
24
25
const FILTER_OUT_PRESETS = [ 'env' ] ;
@@ -28,8 +29,20 @@ const FILTER_OUT_PLUGINS = [
28
29
'transform-destructuring' ,
29
30
] ;
30
31
32
+ const CLASS_PLUGINS = [
33
+ 'transform-class-properties' ,
34
+ 'transform-private-methods' ,
35
+ 'transform-private-property-in-object' ,
36
+ ] ;
37
+
31
38
const PACKAGES_PATH = pathJoin ( import . meta. dirname , '../coverage/babel/packages' ) ;
32
39
40
+ // These fixtures transform incorrectly by Babel. Haven't figured out why yet.
41
+ const IGNORED_FIXTURES = [
42
+ 'compile-to-class/constructor-collision-ignores-types' ,
43
+ 'compile-to-class/constructor-collision-ignores-types-loose' ,
44
+ ] ;
45
+
33
46
// Copied from `@babel/helper-transform-fixture-test-runner`
34
47
const EXTERNAL_HELPERS_VERSION = '7.100.0' ;
35
48
@@ -46,6 +59,10 @@ for (const packageName of PACKAGES) {
46
59
* @returns {undefined }
47
60
*/
48
61
async function updateDir ( dirPath , options , hasChangedOptions ) {
62
+ if ( IGNORED_FIXTURES . some ( p => dirPath . endsWith ( p ) ) ) {
63
+ return ;
64
+ }
65
+
49
66
const files = await readdir ( dirPath , { withFileTypes : true } ) ;
50
67
51
68
const dirFiles = [ ] ,
@@ -118,10 +135,48 @@ function updateOptions(options) {
118
135
119
136
filter ( 'presets' , FILTER_OUT_PRESETS ) ;
120
137
filter ( 'plugins' , FILTER_OUT_PLUGINS ) ;
138
+ if ( ensureAllClassPluginsEnabled ( options ) ) {
139
+ hasChangedOptions = true ;
140
+ }
121
141
122
142
return hasChangedOptions ;
123
143
}
124
144
145
+ // Ensure all class plugins are enabled if any of class related plugins are enabled
146
+ function ensureAllClassPluginsEnabled ( options ) {
147
+ let plugins = options . plugins ;
148
+ if ( ! plugins ) return false ;
149
+
150
+ let already_enabled = [ ] ;
151
+ let pluginOptions ;
152
+ plugins . forEach ( plugin => {
153
+ let pluginName = getName ( plugin ) ;
154
+ if ( CLASS_PLUGINS . includes ( pluginName ) ) {
155
+ if ( Array . isArray ( plugin ) && plugin [ 1 ] ) {
156
+ // Store options for the plugin, so that we can ensure all plugins are
157
+ // enabled with the same options
158
+ pluginOptions = plugin [ 1 ] ;
159
+ }
160
+ already_enabled . push ( pluginName ) ;
161
+ }
162
+ } ) ;
163
+
164
+ if ( already_enabled . length ) {
165
+ CLASS_PLUGINS . forEach ( pluginName => {
166
+ if ( ! already_enabled . includes ( pluginName ) ) {
167
+ if ( pluginOptions ) {
168
+ plugins . push ( [ pluginName , pluginOptions ] ) ;
169
+ } else {
170
+ plugins . push ( pluginName ) ;
171
+ }
172
+ }
173
+ } ) ;
174
+ return true ;
175
+ } else {
176
+ return false ;
177
+ }
178
+ }
179
+
125
180
/**
126
181
* Transform input with Babel and save to output file.
127
182
* @param {string } inputPath - Path of input file
@@ -135,8 +190,13 @@ async function transform(inputPath, options) {
135
190
babelrc : false ,
136
191
cwd : import . meta. dirname ,
137
192
} ;
193
+ delete options . BABEL_8_BREAKING ;
194
+ delete options . validateLogs ;
195
+ delete options . SKIP_ON_PUBLISH ;
138
196
delete options . SKIP_babel7plugins_babel8core ;
139
197
delete options . minNodeVersion ;
198
+ delete options . validateLogs ;
199
+ delete options . SKIP_ON_PUBLISH ;
140
200
141
201
function prefixName ( plugin , type ) {
142
202
if ( Array . isArray ( plugin ) ) {
0 commit comments