@@ -13,20 +13,19 @@ module.exports = {
13
13
// Create `parent.options.autoImport.webpack = {}`
14
14
if ( ! parent . options ) parent . options = { } ;
15
15
if ( ! parent . options . autoImport ) parent . options . autoImport = { } ;
16
+
16
17
const { autoImport } = parent . options ;
18
+
17
19
if ( ! autoImport . webpack ) autoImport . webpack = { } ;
20
+
18
21
const { webpack } = autoImport ;
19
22
20
23
// Unshift `.ts` `.d.ts` extensions to `webpack.resolve.extensions`
21
- if ( ! webpack . resolve )
22
- webpack . resolve = { extensions : [ '.ts' , '.js' , '.d.ts' ] } ;
23
- else if ( ! webpack . resolve . extensions )
24
- webpack . resolve . extensions = [ '.ts' , '.js' , '.d.ts' ] ;
25
- else if ( ! webpack . resolve . extensions . includes ( '.ts' ) )
26
- webpack . resolve . extensions . unshift ( '.ts' ) ;
24
+ if ( ! webpack . resolve ) webpack . resolve = { extensions : [ '.ts' , '.js' , '.d.ts' ] } ;
25
+ else if ( ! webpack . resolve . extensions ) webpack . resolve . extensions = [ '.ts' , '.js' , '.d.ts' ] ;
26
+ else if ( ! webpack . resolve . extensions . includes ( '.ts' ) ) webpack . resolve . extensions . unshift ( '.ts' ) ;
27
27
28
- if ( ! webpack . resolve . extensions . includes ( '.d.ts' ) )
29
- webpack . resolve . extensions . push ( '.d.ts' ) ;
28
+ if ( ! webpack . resolve . extensions . includes ( '.d.ts' ) ) webpack . resolve . extensions . push ( '.d.ts' ) ;
30
29
31
30
const tsModuleRule = {
32
31
test : / \. t s $ / ,
@@ -35,55 +34,40 @@ module.exports = {
35
34
options : {
36
35
plugins : [
37
36
// https://github.com/babel/ember-cli-babel/blob/4c3b9091d7c711ecb804a52226409b409a702d82/lib/babel-options-util.js#L398
38
- [
39
- require . resolve ( '@babel/plugin-transform-typescript' ) ,
40
- { allowDeclareFields : true }
41
- ] ,
37
+ [ require . resolve ( '@babel/plugin-transform-typescript' ) , { allowDeclareFields : true } ] ,
42
38
43
39
// https://github.com/babel/ember-cli-babel/blob/4c3b9091d7c711ecb804a52226409b409a702d82/lib/babel-options-util.js#L324
44
- [
45
- require . resolve ( '@babel/plugin-proposal-decorators' ) ,
46
- { legacy : true }
47
- ] ,
40
+ [ require . resolve ( '@babel/plugin-proposal-decorators' ) , { legacy : true } ] ,
48
41
49
42
// https://github.com/babel/ember-cli-babel/blob/4c3b9091d7c711ecb804a52226409b409a702d82/lib/babel-options-util.js#L348-L349
50
- [
51
- require . resolve ( '@babel/plugin-proposal-class-properties' ) ,
52
- { loose : false }
53
- ] ,
43
+ [ require . resolve ( '@babel/plugin-proposal-class-properties' ) , { loose : false } ] ,
54
44
55
45
// https://github.com/webpack/webpack/issues/10227
56
46
// Remove when `ember-auto-import` updates to `webpack@5`.
57
- require . resolve (
58
- '@babel/plugin-proposal-nullish-coalescing-operator'
59
- ) ,
60
- require . resolve ( '@babel/plugin-proposal-optional-chaining' )
47
+ require . resolve ( '@babel/plugin-proposal-nullish-coalescing-operator' ) ,
48
+ require . resolve ( '@babel/plugin-proposal-optional-chaining' ) ,
61
49
] ,
62
50
presets : [
63
51
// Transpile incompatible syntax for project build targets
64
52
[
65
53
require . resolve ( '@babel/preset-env' ) ,
66
54
{
67
55
modules : false ,
68
- targets : this . project . targets
69
- }
70
- ]
71
- ]
72
- }
73
- }
56
+ targets : this . project . targets ,
57
+ } ,
58
+ ] ,
59
+ ] ,
60
+ } ,
61
+ } ,
74
62
} ;
75
63
76
64
// Push `tsModuleRule` into `webpack.module.rules`
77
65
if ( ! webpack . module ) {
78
66
webpack . module = { rules : [ tsModuleRule ] } ;
79
67
} else if ( ! webpack . module . rules ) {
80
68
webpack . module . rules = [ tsModuleRule ] ;
81
- } else if (
82
- ! webpack . module . rules . some (
83
- r => String ( r . test ) === String ( tsModuleRule . test )
84
- )
85
- ) {
69
+ } else if ( ! webpack . module . rules . some ( ( r ) => String ( r . test ) === String ( tsModuleRule . test ) ) ) {
86
70
webpack . module . rules . push ( tsModuleRule ) ;
87
71
}
88
- }
72
+ } ,
89
73
} ;
0 commit comments