-
-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Misc cleaning #1659
chore: Misc cleaning #1659
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'preact-cli': patch | ||
--- | ||
|
||
Corrects `push-manifest.json` generation in non-ESM builds |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ const cleanFilename = name => | |
* @returns {Promise<import('webpack').Configuration>} | ||
*/ | ||
async function clientConfig(env) { | ||
const { isProd, source, src, cwd /*, port? */ } = env; | ||
const { source, src, cwd } = env; | ||
const IS_SOURCE_PREACT_X_OR_ABOVE = isInstalledVersionPreactXOrAbove(cwd); | ||
const asyncLoader = IS_SOURCE_PREACT_X_OR_ABOVE | ||
? require.resolve('@preact/async-loader') | ||
|
@@ -84,7 +84,7 @@ async function clientConfig(env) { | |
// copy any static files | ||
existsSync(source('assets')) && { from: 'assets', to: 'assets' }, | ||
// copy sw-debug | ||
!isProd && { | ||
!env.isProd && { | ||
from: resolve(__dirname, '../../resources/sw-debug.js'), | ||
to: 'sw-debug.js', | ||
}, | ||
|
@@ -100,7 +100,7 @@ async function clientConfig(env) { | |
output: { | ||
path: env.dest, | ||
publicPath: '/', | ||
filename: isProd ? '[name].[chunkhash:5].js' : '[name].js', | ||
filename: env.isProd ? '[name].[chunkhash:5].js' : '[name].js', | ||
chunkFilename: '[name].chunk.[chunkhash:5].js', | ||
}, | ||
|
||
|
@@ -143,6 +143,8 @@ async function clientConfig(env) { | |
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env.ES_BUILD': false, | ||
'process.env.ADD_SW': env.sw, | ||
'process.env.PRERENDER': env.prerender, | ||
}), | ||
new PushManifestPlugin(env), | ||
...(await renderHTMLPlugin(env)), | ||
|
@@ -156,14 +158,12 @@ async function clientConfig(env) { | |
}; | ||
} | ||
|
||
function getBabelEsmPlugin(config) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Besides a few spots in |
||
function getBabelEsmPlugin(env) { | ||
const esmPlugins = []; | ||
if (config.esm) { | ||
if (env.esm) { | ||
esmPlugins.push( | ||
new BabelEsmPlugin({ | ||
filename: config.isProd | ||
? '[name].[chunkhash:5].esm.js' | ||
: '[name].esm.js', | ||
filename: env.isProd ? '[name].[chunkhash:5].esm.js' : '[name].esm.js', | ||
chunkFilename: '[name].chunk.[chunkhash:5].esm.js', | ||
excludedPlugins: ['BabelEsmPlugin', 'InjectManifest'], | ||
beforeStartExecution: plugins => { | ||
|
@@ -196,7 +196,7 @@ function getBabelEsmPlugin(config) { | |
/** | ||
* @returns {import('webpack').Configuration} | ||
*/ | ||
function isProd(config) { | ||
function isProd(env) { | ||
let limit = 200 * 1000; // 200kb | ||
const prodConfig = { | ||
performance: Object.assign( | ||
|
@@ -205,14 +205,12 @@ function isProd(config) { | |
maxAssetSize: limit, | ||
maxEntrypointSize: limit, | ||
}, | ||
config.pkg.performance | ||
env.pkg.performance | ||
), | ||
|
||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env.ADD_SW': config.sw, | ||
'process.env.ESM': config.esm, | ||
'process.env.PRERENDER': config.prerender, | ||
'process.env.ESM': env.esm, | ||
}), | ||
new SizePlugin(), | ||
], | ||
|
@@ -252,7 +250,7 @@ function isProd(config) { | |
}, | ||
}; | ||
|
||
if (config['inline-css']) { | ||
if (env['inline-css']) { | ||
prodConfig.plugins.push( | ||
new CrittersPlugin({ | ||
preload: 'media', | ||
|
@@ -263,11 +261,11 @@ function isProd(config) { | |
); | ||
} | ||
|
||
if (config.analyze) { | ||
if (env.analyze) { | ||
prodConfig.plugins.push(new BundleAnalyzerPlugin()); | ||
} | ||
|
||
if (config.brotli) { | ||
if (env.brotli) { | ||
prodConfig.plugins.push( | ||
new CompressionPlugin({ | ||
filename: '[path].br[query]', | ||
|
@@ -283,21 +281,17 @@ function isProd(config) { | |
/** | ||
* @returns {import('webpack').Configuration} | ||
*/ | ||
function isDev(config) { | ||
const { cwd, src, refresh } = config; | ||
function isDev(env) { | ||
const { cwd, src } = env; | ||
|
||
return { | ||
infrastructureLogging: { | ||
level: 'info', | ||
}, | ||
plugins: [ | ||
new webpack.NamedModulesPlugin(), | ||
...(refresh ? [new RefreshPlugin()] : []), | ||
new webpack.DefinePlugin({ | ||
'process.env.ADD_SW': config.sw, | ||
'process.env.PRERENDER': config.prerender, | ||
}), | ||
Comment on lines
-296
to
-299
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Values are duplicated with prod config, so they can be moved up to common. |
||
], | ||
env.refresh && new RefreshPlugin(), | ||
].filter(Boolean), | ||
|
||
devServer: { | ||
hot: true, | ||
|
@@ -312,9 +306,9 @@ function isDev(config) { | |
ignored: [resolve(cwd, 'build'), resolve(cwd, 'node_modules')], | ||
}, | ||
}, | ||
https: config.https, | ||
port: config.port, | ||
host: process.env.HOST || config.host || '0.0.0.0', | ||
https: env.https, | ||
port: env.port, | ||
host: process.env.HOST || env.host || '0.0.0.0', | ||
allowedHosts: 'all', | ||
historyApiFallback: true, | ||
client: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,31 +22,6 @@ describe('client-side tests', () => { | |
PORT = await getPort(); | ||
}); | ||
|
||
it.skip('should hydrate routes progressively.', async () => { | ||
let dir = await subject('progressive-hydration'); | ||
await build(dir); | ||
const server = getServer(join(dir, 'build'), PORT); | ||
|
||
// let page = await loadPage(chrome, `http://127.0.0.1:${PORT}/`); | ||
const page = await chrome.newPage(); | ||
|
||
page.on('console', consoleMessage => { | ||
// eslint-disable-next-line | ||
console[consoleMessage.type()](consoleMessage.text()); | ||
}); | ||
|
||
await page.goto(`http://127.0.0.1:${PORT}/`); | ||
|
||
// await waitUntilExpression(page, `window.booted`); | ||
await sleep(500); | ||
|
||
const mutations = await page.evaluate('window.mutations'); | ||
|
||
expect(mutations).toHaveLength(0); | ||
|
||
server.server.close(); | ||
}); | ||
|
||
Comment on lines
-25
to
-49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has been skipped since it was added: #957 |
||
it('should hydrate routes progressively with preact8.', async () => { | ||
let dir = await subject('progressive-hydration-preact8'); | ||
await build(dir, {}, true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This created some junk output in
push-manifest.json
when ESM is disabled, like in our test suite. Wouldn't have ever been a problem, as these junk "routes" would never match to a URL when building the HTML, but certainly looked odd if any user took a peek.