Skip to content
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

Move build directory outside of server folder #4565

Merged
merged 19 commits into from
Jun 14, 2018

Conversation

timneutkens
Copy link
Member

@timneutkens timneutkens commented Jun 8, 2018

The prepares for next-server.

I also took this as an opportunity to get all build directory paths from a single location, as they were previously scattered across webpack/babel plugins and loaders.

@timneutkens timneutkens changed the title Move build directory outside of server folder [WIP] Move build directory outside of server folder Jun 8, 2018
@timneutkens
Copy link
Member Author

next-typescript has to be updated to reflect the changes in hot-self-accept-loader.

You can now use defaultLoaders.hotSelfAccept instead of having the hardcoded configuration. This will make plugins depending on it more future proof.

@timneutkens timneutkens changed the title [WIP] Move build directory outside of server folder Move build directory outside of server folder Jun 10, 2018
throw new Error('include option is not provided to hot-self-accept-loader. Please upgrade all next-plugins to the latest version.')
}

const dir = options.include.find((d) => resourcePath.indexOf(d) === 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the indexOf outside of the predicate to a variable and use that in here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How'd you mean 🤔

import loaderUtils from 'loader-utils'

module.exports = function (content, sourceMap) {
type Options = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be an exact type? {||}

include: [
path.join(dir, 'pages')
],
extensions: /\.(js|jsx)$/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick, but how about jsx? 🏌️‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended to not confuse people reading the code.

lib/constants.js Outdated
@@ -12,3 +13,9 @@ export const BLOCKED_PAGES = [
'/_app',
'/_error'
]
export const IS_BUNDLED_PAGE = /^bundles[/\\]pages.*\.js$/
export const MATCH_ROUTE_NAME = /^bundles[/\\]pages[/\\](.*)\.js$/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious that these are Regexs. what do you think about BUNDLE_PAGE_REGEX and ROUTE_NAME_REGEX?

readme.md Outdated
- `buildId` - `String` the build id used as a unique identifier between builds
- `dev` - `Boolean` shows if the compilation is done in development mode
- `isServer` - `Boolean` shows if the resulting configuration will be used for server side (`true`), or client size compilation (`false`).
- `defaultLoaders` - `Object` Holds loaders Next.js uses internally, so that you can use them in custom configuration

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. Does defaultLoaders hold the loader objects themselves, or just the configuration objects for the loaders?

Copy link

@pranaygp pranaygp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of it looks great. Read comments above 👍

readme.md Outdated
module.exports = {
webpack: (config, {}) => {
config.module.rules.push({
test: extension,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we say test: /mdx?/ for the example?

server/utils.js Outdated
export function getChunkNameFromFilename (filename) {
export function getChunkNameFromFilename (filename, dev) {
if (dev) {
return filename.replace(/.[^.]*$/, '')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, is this because webpack handles naming different based on NODE_ENV?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, with chunk hash or without, but I didn't change this. It's from another PR.

Copy link

@pranaygp pranaygp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@timneutkens timneutkens merged commit f2c2519 into vercel:canary Jun 14, 2018
@timneutkens timneutkens deleted the add/move-build branch June 14, 2018 17:30
lependu pushed a commit to lependu/next.js that referenced this pull request Jun 19, 2018
The prepares for next-server.

I also took this as an opportunity to get all build directory paths from a single location, as they were previously scattered across webpack/babel plugins and loaders.
@lock lock bot locked as resolved and limited conversation to collaborators Jun 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants