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

Example: Externals - config for untranspiled external packages #3732

Closed
wants to merge 1 commit into from

Conversation

ghengeveld
Copy link

This provides an example next.config.js which adds support for external untranspiled npm packages. It overrides Webpack's externals so it will process these packages and configures webpack-dev-server to enable HMR on npm linked local packages.

@ghengeveld ghengeveld changed the title Create example config for untranspiled external packages. Example: Externals - config for untranspiled external packages Feb 8, 2018
})
config.module.rules.push({
test: /\.+(js|jsx)$/,
loader: defaultLoaders.babel,
Copy link

Choose a reason for hiding this comment

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

Does this respect my local babel config? Trying this out but wouldn't process stage-2.

Copy link

Choose a reason for hiding this comment

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

Never mind, it does work!

Copy link
Member

Choose a reason for hiding this comment

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

Yep defaultLoaders.babel is provided by next to be integrated into plugins / next.config.js. It's the same babel config used to configure .js transpilation 🙏

Copy link

@muthukumarsp muthukumarsp Apr 23, 2018

Choose a reason for hiding this comment

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

A fully working example will help a lot

Choose a reason for hiding this comment

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

I can say that this next.config.js does indeed work. I took what's here and tested in my own project (Lerna based).

const webpack = require("webpack")

// Update these to match your package scope name.
const internalNodeModulesRegExp = /@zeit(?!.*node_modules)/

Choose a reason for hiding this comment

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

A little confused by how this works. The internalNodeModulesRegExp won't replace the scan to our internal node_modules right?

And what's the externalNodeModules? seems like it's used to ignore a re-compile in webpackDevServer?

Copy link

@gpolyn gpolyn May 1, 2018

Choose a reason for hiding this comment

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

Yup, I don't get this part either.

@andrewmclagan
Copy link
Contributor

Whats remaining on blocking this merge? Happy to help.

@trusktr
Copy link

trusktr commented Sep 4, 2018

Does this work with next-typescript if I change test: /\.+(js|jsx)$/, to test: /\.+(ts|tsx)$/,?

@@ -0,0 +1,26 @@
const webpack = require("webpack")
Copy link

@trusktr trusktr Sep 4, 2018

Choose a reason for hiding this comment

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

Why is webpack imported here? Is this needed?

@timneutkens
Copy link
Member

Going to close this in favor of https://github.com/zeit/next.js/blob/canary/examples/with-yarn-workspaces/packages/web-app/next.config.js

@timneutkens timneutkens closed this Sep 5, 2018
@martpie
Copy link
Contributor

martpie commented Sep 5, 2018

@timneutkens I am the maintainer of next-plugin-transpile-modules, would you like I create an example more "focused" than "with yarn workspaces". Like example/with-transpiled-modules?

@lamtranweb
Copy link

@martpie next-plugin-transpile-modules no longer works with nextjs@7.0.0 -- most likely because of Webpack 4 change...

@martpie
Copy link
Contributor

martpie commented Sep 20, 2018

Thank you for noticing that, I'll have a look

@lock lock bot locked as resolved and limited conversation to collaborators Sep 20, 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.

10 participants