File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const args = parseArgs({
2222
2323async function main ( ) {
2424 const packageRoot = path . resolve ( process . cwd ( ) , args . positionals [ 0 ] ) ;
25+ const isWatch = args . values . watch || false ;
2526
2627 if ( ! fs . existsSync ( packageRoot ) ) {
2728 console . error ( `The package directory "${ packageRoot } " does not exist.` ) ;
@@ -86,9 +87,9 @@ async function main() {
8687 process . exit ( 1 ) ;
8788 }
8889
89- const rollupConfig = getRollupConfiguration ( { packageRoot, inputFiles : inputScriptFiles } ) ;
90+ const rollupConfig = getRollupConfiguration ( { packageRoot, inputFiles : inputScriptFiles , isWatch } ) ;
9091
91- if ( args . values . watch ) {
92+ if ( isWatch ) {
9293 console . log (
9394 `Watching for JavaScript${ inputStyleFile ? ' and CSS' : '' } files modifications in "${ srcDir } " directory...`
9495 ) ;
@@ -103,9 +104,13 @@ async function main() {
103104 }
104105
105106 const watcher = rollup . watch ( rollupConfig ) ;
106- watcher . on ( 'event' , ( { result } ) => {
107- if ( result ) {
108- result . close ( ) ;
107+ watcher . on ( 'event' , ( event ) => {
108+ if ( event . code === 'ERROR' ) {
109+ console . error ( 'Error during build:' , event . error ) ;
110+ }
111+
112+ if ( event . result ) {
113+ event . result . close ( ) ;
109114 }
110115 } ) ;
111116 watcher . on ( 'change' , async ( id , { event } ) => {
Original file line number Diff line number Diff line change @@ -72,8 +72,9 @@ const moveTypescriptDeclarationsPlugin = (packageRoot) => ({
7272/**
7373 * @param {String } packageRoot
7474 * @param {Array<String> } inputFiles
75+ * @param {Boolean } isWatch
7576 */
76- function getRollupConfiguration ( { packageRoot, inputFiles } ) {
77+ function getRollupConfiguration ( { packageRoot, inputFiles, isWatch } ) {
7778 const packagePath = path . join ( packageRoot , 'package.json' ) ;
7879 const packageData = JSON . parse ( fs . readFileSync ( packagePath , 'utf8' ) ) ;
7980 const peerDependencies = [
@@ -108,7 +109,7 @@ function getRollupConfiguration({ packageRoot, inputFiles }) {
108109 typescript ( {
109110 filterRoot : '.' ,
110111 tsconfig : path . join ( __dirname , '..' , 'tsconfig.json' ) ,
111- noEmitOnError : true ,
112+ noEmitOnError : ! isWatch ,
112113 include : [
113114 'src/**/*.ts' ,
114115 // TODO: Remove for the next major release
You can’t perform that action at this time.
0 commit comments