Skip to content

Conversation

@impronunciable
Copy link
Contributor

Fixes #728

(and it's pretty cool)

server/index.js Outdated

this.router.get('/_webpack/:number', async (req, res, params) => {
if (isNaN(params.number)) throw new Error('Webpack dynamic imports should be numbered')
const p = join(this.dir, `.next/${params.number}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be join(this.dir, '.next', params.number) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll change it

await serveStatic(req, res, p)
})

this.router.get('/_webpack/:number', async (req, res, params) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In what case?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also am not sure exactly when this path is used, but some files, like patch files of HMR, are served from it.

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I read #728, is this intentional ? Anyway it would be better to use a same logic to serve these files on dev and production IMO.

Copy link
Contributor

@arunoda arunoda Jan 11, 2017

Choose a reason for hiding this comment

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

I think here _webpack is the path we exposed as publicPath in the config.

I think in the dev mode, this is implemented by the webpack dev server itself. We only need to do this on production.

Copy link
Contributor

Choose a reason for hiding this comment

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

@arunoda makes sense

Copy link
Contributor

@arunoda arunoda Jan 12, 2017

Choose a reason for hiding this comment

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

So, shall we add this route only in the production mode? So we are sure, we don't interfere with the webpack dev server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So with an if ( dev ) this should be ok @nkzawa ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any thoughts?

@rauchg rauchg added this to the 2.1 milestone Jan 12, 2017
})

this.router.get('/_webpack/:number', async (req, res, params) => {
if (isNaN(params.number)) throw new Error('Webpack dynamic imports should be numbered')
Copy link
Contributor

@nkzawa nkzawa Jan 12, 2017

Choose a reason for hiding this comment

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

We should respond with appropriate status code (404) ?

@arunoda
Copy link
Contributor

arunoda commented Mar 12, 2017

We are working on something similar on the import-then branch.

@impronunciable
Copy link
Contributor Author

@arunoda should we close this then?

@arunoda
Copy link
Contributor

arunoda commented Mar 15, 2017

YEAH!

@arunoda arunoda deleted the feature/dynamic-imports branch March 15, 2017 16:03
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 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.

5 participants