@@ -72,40 +72,6 @@ function ast (source) {
72
72
return ast ;
73
73
}
74
74
75
- function parseDep ( issuer , dep ) {
76
- return this . compilation . resolvers . normal . resolve ( { issuer : issuer } , path . dirname ( issuer ) , dep . module , { } ) . then ( rst => {
77
- let npm = rst . meta . descriptionFileRoot !== this . compilation . context ;
78
-
79
- let assets = this . compilation . assets ;
80
-
81
- if ( ! rst . path ) {
82
- return rst . path ;
83
- }
84
- let id = assets . get ( rst . path ) ;
85
- if ( id !== undefined ) {
86
- return id ;
87
- }
88
-
89
-
90
- let ext = path . extname ( rst . path ) ;
91
-
92
- if ( ext === '.js' ) {
93
- if ( npm ) {
94
- return this . parse ( {
95
- code : fs . readFileSync ( rst . path , 'utf-8' )
96
- } , {
97
- file : rst . path ,
98
- npm : npm
99
- } ) ;
100
- }
101
- } else if ( ext === this . compilation . options . wpyExt ) {
102
- return this . compilation . parsers . wpy . parse ( rst . path ) ;
103
- }
104
- } ) . catch ( e => {
105
- console . error ( e ) ;
106
- } ) ;
107
- }
108
-
109
75
exports = module . exports = function ( ) {
110
76
111
77
this . register ( 'wepy-parser-dep' , function ( node , ctx , dep ) {
@@ -155,10 +121,10 @@ exports = module.exports = function () {
155
121
let assets = this . assets ;
156
122
let npmModules = this . npm ;
157
123
if ( ctx . npm ) {
158
- if ( assets . pending ( ctx . file ) ) {
159
- return Promise . resolve ( assets . get ( ctx . file ) ) ;
124
+ if ( this . vendors . pending ( ctx . file ) ) {
125
+ return Promise . resolve ( this . vendors . get ( ctx . file ) ) ;
160
126
}
161
- assets . add ( ctx . file , 'npm' ) ;
127
+ this . vendors . add ( ctx . file , 'npm' ) ;
162
128
}
163
129
164
130
let source = new ReplaceSource ( new RawSource ( node . compiled . code ) ) ;
@@ -174,15 +140,17 @@ exports = module.exports = function () {
174
140
} ) ;
175
141
176
142
return Promise . all ( depTasks ) . then ( rst => {
143
+ let type = ctx . npm ? 'npm' : ( ctx . sfc ? 'component' : 'require' ) ;
177
144
let obj = {
178
145
file : ctx . file ,
179
146
parser : walker ,
180
147
code : node . compiled . code ,
181
148
source : source ,
182
- depModules : rst
149
+ depModules : rst ,
150
+ type : type
183
151
} ;
184
- let assets = this . assets ;
185
- assets . update ( ctx . file , obj , ctx . npm ? 'npm' : ( ctx . sfc ? 'app' : 'require' ) ) ;
152
+ let assets = ctx . npm ? this . vendors : this . assets ;
153
+ assets . update ( ctx . file , obj , type ) ;
186
154
obj . id = assets . get ( ctx . file ) ;
187
155
return obj ;
188
156
} ) ;
0 commit comments