Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/asset-manifest
- Loading branch information
Showing
26 changed files
with
1,526 additions
and
1,335 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'preact-cli': patch | ||
--- | ||
|
||
Allows users to author prerender-urls.js as ESM once again |
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
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
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
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,63 @@ | ||
const { join } = require('path'); | ||
const { access } = require('fs').promises; | ||
const { build } = require('./lib/cli'); | ||
const { subject } = require('./lib/output'); | ||
|
||
const formats = ['cjs', 'esm']; | ||
|
||
const prerenderUrlFiles = [ | ||
'array.js', | ||
'stringified-array.js', | ||
'function-returning-array.js', | ||
'function-returning-stringified-array.js', | ||
]; | ||
|
||
const preactConfigFiles = ['function.js', 'object.js']; | ||
|
||
describe('config files', () => { | ||
describe('prerender-urls', () => { | ||
it(`should load the 'prerender-urls.json' file`, async () => { | ||
let dir = await subject('multiple-config-files'); | ||
|
||
await build(dir); | ||
|
||
expect(await access(join(dir, 'build/index.html'))).toBeUndefined(); | ||
expect( | ||
await access(join(dir, 'build/custom/index.html')) | ||
).toBeUndefined(); | ||
}); | ||
|
||
formats.forEach(moduleFormat => { | ||
prerenderUrlFiles.forEach(dataFormat => { | ||
it(`should load the '${dataFormat}' file in ${moduleFormat}`, async () => { | ||
let dir = await subject('multiple-config-files'); | ||
|
||
await build(dir, { | ||
prerenderUrls: `prerenderUrls/${moduleFormat}/${dataFormat}`, | ||
}); | ||
|
||
expect(await access(join(dir, 'build/index.html'))).toBeUndefined(); | ||
expect( | ||
await access(join(dir, 'build/custom/index.html')) | ||
).toBeUndefined(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('preact.config', () => { | ||
formats.forEach(moduleFormat => { | ||
preactConfigFiles.forEach(dataFormat => { | ||
it(`should load the '${dataFormat}' file in ${moduleFormat}`, async () => { | ||
let dir = await subject('multiple-config-files'); | ||
|
||
await build(dir, { | ||
config: `preactConfig/${moduleFormat}/${dataFormat}`, | ||
}); | ||
|
||
expect(await access(join(dir, 'build/bundle.js'))).toBeUndefined(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/cli/tests/subjects/multiple-config-files/index.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,19 @@ | ||
import { h, Component } from 'preact'; | ||
import { Router } from 'preact-router'; | ||
import Home from './routes/home'; | ||
|
||
export default class App extends Component { | ||
handleRoute = e => { | ||
this.currentUrl = e.url; | ||
}; | ||
|
||
render(props) { | ||
return ( | ||
<div id="app"> | ||
<Router url={props.url} onChange={this.handleRoute} {...props}> | ||
<Home path="/" /> | ||
</Router> | ||
</div> | ||
); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/cli/tests/subjects/multiple-config-files/package.json
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,4 @@ | ||
{ | ||
"private": true, | ||
"name": "preact-config" | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/cli/tests/subjects/multiple-config-files/preactConfig/cjs/function.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 @@ | ||
module.exports = function (config) { | ||
config.output.filename = '[name].js'; | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/cli/tests/subjects/multiple-config-files/preactConfig/cjs/object.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,5 @@ | ||
module.exports = { | ||
webpack(config) { | ||
config.output.filename = '[name].js'; | ||
}, | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/cli/tests/subjects/multiple-config-files/preactConfig/esm/function.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 @@ | ||
export default function (config) { | ||
config.output.filename = '[name].js'; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/cli/tests/subjects/multiple-config-files/preactConfig/esm/object.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,5 @@ | ||
export default { | ||
webpack(config) { | ||
config.output.filename = '[name].js'; | ||
}, | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/cli/tests/subjects/multiple-config-files/prerender-urls.json
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,8 @@ | ||
[ | ||
{ | ||
"url": "/" | ||
}, | ||
{ | ||
"url": "/custom" | ||
} | ||
] |
8 changes: 8 additions & 0 deletions
8
packages/cli/tests/subjects/multiple-config-files/prerenderUrls/cjs/array.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,8 @@ | ||
module.exports = [ | ||
{ | ||
url: '/', | ||
}, | ||
{ | ||
url: '/custom', | ||
}, | ||
]; |
8 changes: 8 additions & 0 deletions
8
...es/cli/tests/subjects/multiple-config-files/prerenderUrls/cjs/function-returning-array.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,8 @@ | ||
module.exports = () => [ | ||
{ | ||
url: '/', | ||
}, | ||
{ | ||
url: '/custom', | ||
}, | ||
]; |
8 changes: 8 additions & 0 deletions
8
.../subjects/multiple-config-files/prerenderUrls/cjs/function-returning-stringified-array.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,8 @@ | ||
module.exports = () => `[ | ||
{ | ||
"url": "/" | ||
}, | ||
{ | ||
"url": "/custom" | ||
} | ||
]`; |
8 changes: 8 additions & 0 deletions
8
packages/cli/tests/subjects/multiple-config-files/prerenderUrls/cjs/stringified-array.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,8 @@ | ||
module.exports = `[ | ||
{ | ||
"url": "/" | ||
}, | ||
{ | ||
"url": "/custom" | ||
} | ||
]`; |
8 changes: 8 additions & 0 deletions
8
packages/cli/tests/subjects/multiple-config-files/prerenderUrls/esm/array.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,8 @@ | ||
export default [ | ||
{ | ||
url: '/', | ||
}, | ||
{ | ||
url: '/custom', | ||
}, | ||
]; |
8 changes: 8 additions & 0 deletions
8
...es/cli/tests/subjects/multiple-config-files/prerenderUrls/esm/function-returning-array.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,8 @@ | ||
export default () => [ | ||
{ | ||
url: '/', | ||
}, | ||
{ | ||
url: '/custom', | ||
}, | ||
]; |
8 changes: 8 additions & 0 deletions
8
.../subjects/multiple-config-files/prerenderUrls/esm/function-returning-stringified-array.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,8 @@ | ||
export default () => `[ | ||
{ | ||
"url": "/" | ||
}, | ||
{ | ||
"url": "/custom" | ||
} | ||
]`; |
Oops, something went wrong.