Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af6a284
commit ccd3ceb
Showing
23 changed files
with
203 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
let mainFile; | ||
|
||
module.exports = { | ||
description: 'recovers from errors during bundling', | ||
command: 'rollup -cw', | ||
before() { | ||
mainFile = path.resolve(__dirname, 'main.js'); | ||
fs.writeFileSync(mainFile, '<=>'); | ||
}, | ||
abortOnStderr(data) { | ||
if (data.includes('Error: Unexpected token')) { | ||
setTimeout(() => fs.writeFileSync(mainFile, 'export default 42;'), 50); | ||
return false; | ||
} | ||
if (data.includes('created _actual')) { | ||
return true; | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var main = 42; | ||
|
||
export default main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 42; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
input: 'main.js', | ||
output: { | ||
dir: "_actual", | ||
format: "es" | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
description: 'watches without a config file', | ||
command: 'rollup main.js --watch --format es --file _actual/main.js', | ||
abortOnStderr(data) { | ||
if (data.includes('created _actual/main.js')) { | ||
return true; | ||
} | ||
}, | ||
}; |
2 changes: 1 addition & 1 deletion
2
...s/watch/watch-config/_expected/output3.js → ...es/watch/no-config-file/_expected/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
const foo = 47; | ||
const foo = 42; | ||
|
||
export { foo }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo = 42; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
description: 'watches using a node_modules config files', | ||
command: 'rollup --watch --config node:custom', | ||
abortOnStderr(data) { | ||
if (data.includes('created _actual/main.js')) { | ||
return true; | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const foo = 42; | ||
|
||
export { foo }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo = 42; |
7 changes: 7 additions & 0 deletions
7
test/cli/samples/watch/node-config-file/node_modules/rollup-config-custom/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
test/cli/samples/watch/node-config-file/node_modules/rollup-config-custom/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
test/cli/samples/watch/watch-config-early-update/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
let configFile; | ||
let messageFile; | ||
let reloadTriggered = false; | ||
|
||
module.exports = { | ||
description: 'immediately reloads the config file if a change happens while it is parsed', | ||
command: 'rollup -cw', | ||
before() { | ||
configFile = path.resolve(__dirname, 'rollup.config.js'); | ||
messageFile = path.resolve(__dirname, '_actual', 'message.txt'); | ||
fs.mkdirSync(path.resolve(__dirname, '_actual')); | ||
fs.writeFileSync(messageFile, 'initial'); | ||
fs.writeFileSync( | ||
configFile, | ||
` | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
const messageFile = path.resolve(__dirname, '_actual', 'message.txt'); | ||
export default new Promise(resolve => { | ||
fs.writeFileSync(messageFile, 'loading'); | ||
const watcher = fs.watch(messageFile, event => { | ||
if (event === 'change') { | ||
const content = fs.readFileSync(messageFile, 'utf8'); | ||
if (content === 'loaded') { | ||
watcher.close(); | ||
fs.writeFileSync(messageFile, 'resolved'); | ||
resolve({ | ||
input: {output1: "main.js"}, | ||
output: { | ||
dir: "_actual", | ||
format: "es" | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
}); | ||
` | ||
); | ||
const watcher = fs.watch(messageFile, (event) => { | ||
if (event === 'change') { | ||
const content = fs.readFileSync(messageFile, 'utf8'); | ||
if (content === 'loading') { | ||
watcher.close(); | ||
fs.writeFileSync( | ||
configFile, | ||
` | ||
export default { | ||
input: {output2: "main.js"}, | ||
output: { | ||
dir: "_actual", | ||
format: "es" | ||
} | ||
}; | ||
` | ||
); | ||
fs.writeFileSync(messageFile, 'loaded'); | ||
} | ||
} | ||
}); | ||
}, | ||
abortOnStderr(data) { | ||
if (reloadTriggered && data.includes('created _actual')) { | ||
return true; | ||
} else if (data.includes('Reloading updated config')) { | ||
reloadTriggered = true; | ||
return false; | ||
} | ||
}, | ||
}; |
1 change: 1 addition & 0 deletions
1
test/cli/samples/watch/watch-config-early-update/_expected/message.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
resolved |
3 changes: 3 additions & 0 deletions
3
test/cli/samples/watch/watch-config-early-update/_expected/output2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const foo = 42; | ||
|
||
export { foo }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo = 42; |
9 changes: 9 additions & 0 deletions
9
test/cli/samples/watch/watch-config-early-update/rollup.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
export default { | ||
input: {output2: "main.js"}, | ||
output: { | ||
dir: "_actual", | ||
format: "es" | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters