File tree Expand file tree Collapse file tree 2 files changed +58
-8
lines changed Expand file tree Collapse file tree 2 files changed +58
-8
lines changed Original file line number Diff line number Diff line change @@ -50,9 +50,21 @@ async function bundleModule(module) {
50
50
}
51
51
52
52
async function processScript ( filePath ) {
53
- let { ast, code } = await babel . transformFileAsync ( path . resolve ( filePath ) , {
54
- ast : true ,
55
- } ) ;
53
+ let ast , code ;
54
+ try {
55
+ const result = await babel . transformFileAsync ( path . resolve ( filePath ) , {
56
+ ast : true ,
57
+ } ) ;
58
+ ast = result . ast ;
59
+ code = result . code ;
60
+ } catch ( error ) {
61
+ console . error ( `Failed to compile ${ filePath } ` ) ;
62
+
63
+ if ( __PROD__ ) throw error ;
64
+
65
+ console . error ( error ) ;
66
+ return ;
67
+ }
56
68
57
69
if ( filePath . endsWith ( 'app.js' ) ) {
58
70
/**
@@ -103,7 +115,20 @@ async function processTemplate(filePath) {
103
115
async function processStyle ( filePath ) {
104
116
const source = await fs . readFile ( filePath , 'utf8' ) ;
105
117
const { plugins, options } = await postcssrc ( { from : undefined } ) ;
106
- const { css } = await postcss ( plugins ) . process ( source , options ) ;
118
+
119
+ let css ;
120
+ try {
121
+ const result = await postcss ( plugins ) . process ( source , options ) ;
122
+ css = result . css ;
123
+ } catch ( error ) {
124
+ console . error ( `Failed to compile ${ filePath } ` ) ;
125
+
126
+ if ( __PROD__ ) throw error ;
127
+
128
+ console . error ( error ) ;
129
+ return ;
130
+ }
131
+
107
132
const destination = filePath
108
133
. replace ( 'src' , 'dist' )
109
134
. replace ( / \. c s s $ / , '.wxss' ) ;
Original file line number Diff line number Diff line change @@ -50,9 +50,21 @@ async function bundleModule(module) {
50
50
}
51
51
52
52
async function processScript ( filePath ) {
53
- let { ast, code } = await babel . transformFileAsync ( path . resolve ( filePath ) , {
54
- ast : true ,
55
- } ) ;
53
+ let ast , code ;
54
+ try {
55
+ const result = await babel . transformFileAsync ( path . resolve ( filePath ) , {
56
+ ast : true ,
57
+ } ) ;
58
+ ast = result . ast ;
59
+ code = result . code ;
60
+ } catch ( error ) {
61
+ console . error ( `Failed to compile ${ filePath } ` ) ;
62
+
63
+ if ( __PROD__ ) throw error ;
64
+
65
+ console . error ( error ) ;
66
+ return ;
67
+ }
56
68
57
69
if ( filePath . endsWith ( 'app.ts' ) ) {
58
70
/**
@@ -103,7 +115,20 @@ async function processTemplate(filePath) {
103
115
async function processStyle ( filePath ) {
104
116
const source = await fs . readFile ( filePath , 'utf8' ) ;
105
117
const { plugins, options } = await postcssrc ( { from : undefined } ) ;
106
- const { css } = await postcss ( plugins ) . process ( source , options ) ;
118
+
119
+ let css ;
120
+ try {
121
+ const result = await postcss ( plugins ) . process ( source , options ) ;
122
+ css = result . css ;
123
+ } catch ( error ) {
124
+ console . error ( `Failed to compile ${ filePath } ` ) ;
125
+
126
+ if ( __PROD__ ) throw error ;
127
+
128
+ console . error ( error ) ;
129
+ return ;
130
+ }
131
+
107
132
const destination = filePath
108
133
. replace ( 'src' , 'dist' )
109
134
. replace ( / \. c s s $ / , '.wxss' ) ;
You can’t perform that action at this time.
0 commit comments