1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/server/build/plugins
João Granado 8c6a4ebb1d Fix generated page chunk when libraryTarget is umd (#4205)
This fixes the generated page chunk created by the webpack `pages-plugin` which adds a new line in the beginning of the template, when using `output.libraryTarget` set to be [`umd`](https://webpack.js.org/configuration/output/#module-definition-systems) it returns the module.

Consider the following example, which is the output with the previous implementation:

```js
(function webpackUniversalModuleDefinition(root, factory) {
  if(typeof exports === 'object' && typeof module === 'object')
    module.exports = factory();
  else if(typeof define === 'function' && define.amd)
    define([], factory);
  else if(typeof exports === 'object')
    exports["MyLibrary"] = factory();
  else
    root["MyLibrary"] = factory();
})(typeof self !== 'undefined' ? self : this, function() {
  return
    __NEXT_REGISTER_PAGE(...)
});
```

`__NEXT_REGISTER_PAGE()` won't be executed since a `return` statement followed by a new line is the same as having a semicolon inserted right after the `return`. By removing the new line in the beginning of the source concatenation (which I suppose was added for stylistic reasons) this works as expected.
2018-05-25 14:23:44 +02:00
..
build-manifest-plugin.js Add build manifest (#4119) 2018-04-12 09:47:42 +02:00
dynamic-chunks-plugin.js Remove buildId from dynamic import URLs (#3498) 2017-12-27 19:59:17 +01:00
nextjs-ssr-import.js [SSR] Use relative paths in dynamic import output code (#3844) 2018-02-19 11:49:41 +01:00
pages-manifest-plugin.js Add export of homepage when exporting without exportPathMap (#4253) 2018-05-02 10:37:52 -07:00
pages-plugin.js Fix generated page chunk when libraryTarget is umd (#4205) 2018-05-25 14:23:44 +02:00
unlink-file-plugin.js Remove mz-fs and glob-promise (#4026) 2018-03-30 20:29:42 +05:30