Commit graph

1293 commits

Author SHA1 Message Date
JJ Kasper
0eab07b7e8
Add automatic TypeScript setup (#7125)
* replace fkill with tree-kill
2019-05-08 21:51:23 -05:00
Joe Haddad
9f4904ff10 Integrate type checking into compilation pipeline (#7278) 2019-05-07 20:11:56 -05:00
JJ Kasper
41c6d92d25 Revert migrating babel-loader into Next.js (#7265)
clearing of stale babel cache
2019-05-07 14:24:47 +02:00
Joe Haddad
948948f6be Fix application output (#7264) 2019-05-06 15:22:54 +02:00
JJ Kasper
c421c259ec Fix webpack fetch error (#7253)
* Add devtool to AutoDllPlugin to prevent
react-error-overlay from attempting to
fetch webpack://

* Fix map file being added as script
2019-05-05 13:03:13 +02:00
JJ Kasper
75203eb8d2
Fix missing injectCaller (#7223) 2019-05-02 17:20:27 -05:00
JJ Kasper
8b92b8b7ce Clear stale files from Next.js' babel-loader cache (#7221)
* Move babel-loader into next all the way converting
it to TypeScript and added tracking of babel-loader
cache so we can clear previous files

* Add license from babel-loader

* Apply suggestions from code review

Co-Authored-By: ijjk <jj@jjsweb.site>

* Make sure to catch errors in next-babel-loader
2019-05-02 16:30:41 -04:00
JJ Kasper
2e8088e447
Add stats to build tree (#7194)
* Copy pretty-bytes instead of installing
2019-05-01 15:31:08 -05:00
Keanu Lee
d0ca9c9eb5 Clean up code/testing artifacts from #7014 (#7211) 2019-05-01 13:56:35 -05:00
Keanu Lee
d120f14d1c Use modern syntax in Next client code (e.g. async await) (#7014)
* Use async/await in build output

* Run next client libraries through plugin-transform-modules-commonjs

* Fix missing includes
2019-05-01 19:16:52 +02:00
JJ Kasper
ceb60b650a
revert nccing webpack (#7189) 2019-04-28 15:35:40 -05:00
Connor Davis
f66546f950
Use ncc to bundle webpack (#6347) 2019-04-26 17:24:30 -05:00
Joe Haddad
13f6804503
Don't resolve ts|tsx for non-TypeScript users (#7173)
* Don't resolve ts|tsx for non-TypeScript users

* Add missing prettier file

* Add tsconfig.json file
2019-04-27 01:12:40 +09:00
Joe Haddad
5cc8079946
Run Prettier on webpack configuration (#7172) 2019-04-27 00:23:32 +09:00
Joe Haddad
265b02f2a9 Purge Terser Cache When Using Flying Shuttle (#7170) 2019-04-26 15:08:37 +02:00
Joe Haddad
3daa473e6d
Disable Terser Cache When Using Flying Shuttle (#7168) 2019-04-26 21:47:57 +09:00
JJ Kasper
5aba5e62fe
Add warning for @zeit/next-typescript (#7163) 2019-04-25 15:49:39 -05:00
Joe Haddad
072bdfbf21
Extra chunks shouldn't deopt Flying Shuttle (#7156) 2019-04-26 00:09:57 +09:00
Tim Neutkens
047bcca4bf
Add support for .ts / .tsx import without extension (#7152) 2019-04-25 11:14:12 +02:00
Connor Davis
ef7c22385a
Replace --target serverless with env var (#7146) 2019-04-25 04:16:30 +09:00
Connor Davis
8582366aa5 Add --target serverless flag (#7141) 2019-04-24 20:32:15 +02:00
Joe Haddad
0c3018c6ce
A webpack bug is preventing us from hashing chunks (#7142) 2019-04-25 01:50:29 +09:00
Joe Haddad
0138ef090a
Remove old debugging logs (#7139) 2019-04-25 01:01:56 +09:00
Joe Haddad
477bdb9299
TypeScript preset should always be enabled (#7137)
The preset handles file toggling itself, and actually changes behavior between `.ts` and `.tsx`.
2019-04-25 00:10:27 +09:00
Martin Šťovíček
05e525443b Always use AllModulesIdentifiedPlugin after HashedModuleIdsPlugin (#7138)
Remove selectivePageBuilding check during build.

Fixes #7109
2019-04-25 00:09:39 +09:00
Joe Haddad
8cd21a6368 Server file inclusive Flying Shuttle (#7128)
* Add Flying Shuttle plugin to server compilation

* Ignore build artifacts in flying shuttle manifest

* Add comments explaining what's going on

* Emit Shuttle manifest after both compilations
2019-04-24 11:04:36 +02:00
JJ Kasper
a320dc10f6 Add AMP label to AMP only pages in build tree (#7123) 2019-04-24 10:48:43 +02:00
Luis Fernando Alvarez D
254b23eb07
Add declaration files to /dist (#7118) 2019-04-23 16:12:33 -05:00
Tim Neutkens
c79558328e
Add Typescript compilation (#7110) 2019-04-23 11:54:08 +02:00
Joe Haddad
2b7ca40622 Revert "Detect built ins in externals (#7083)" (#7107)
This reverts commit f8978cc29c.
2019-04-23 09:09:48 +02:00
Tim Neutkens
c0a10b9960
Wait for entry to resolve in production build (#7104)
* Wait for entry to resolve in production build

* Return promise
2019-04-22 20:57:02 +02:00
Joe Haddad
597138f359
Cache Babel and AutoDll plugin in dirDir/cache (#7102)
* Cache Babel and AutoDll plugin in `dirDir/cache`

* Extract code
2019-04-23 01:16:42 +09:00
JJ Kasper
80210bc31a Update removing AMP pages to not require during build (#7081)
* Update to use babel plugin with webpack plugin to
remove AMP client bundles since they are not used

* Remove acorn dependency since it isn't used
2019-04-22 06:25:17 +09:00
Joe Haddad
f5be84e4ff Upgrade Terser (#6981)
The new version of Terser seems to be significantly slower than the previous.  I wanted to see what our stats PR says.
2019-04-22 06:03:57 +09:00
Luis Fernando Alvarez D
08937807f6 Remove dynamic-import-node from the preset (#7096)
Related to [this spectrum post](https://spectrum.chat/next-js/general/next-8-minor-update-breaks-dynamic-import-in-jest-tests~1e7b58e7-e301-4ef9-9de4-eef6ed3639d4).

I'm not removing the `babel-plugin-dynamic-import-node` package as it's going to be used by #7016
2019-04-22 05:25:48 +09:00
Connor Davis
f8978cc29c Detect built ins in externals (#7083) 2019-04-20 10:44:39 +09:00
Joe Haddad
35236690c0
Disable Terser loader when debugging (#7079) 2019-04-19 13:26:30 +09:00
JJ Kasper
59b328b5c3 Remove client bundles for AMP only pages (#7034)
* Remove client bundles for AMP pages
after build since they are not used

* Remove trailing white space

* Use async-sema to limit removing AMP client bundles

* Bring AMP client bundle removing
semaphore concurrency down to 20

* Don't check blocked pages when
deleting AMP client bundles

* Update client bundle removing for AMP pages

* Add error handling for removing client AMP pages

* rethrow error unless ENOENT during
deleting AMP client pages

* Handle error during removing AMP client
pages the same during dev

* Fix throwing instead of rejecting

* Make sure next/config is set before requiring page

* Update error check

* return on reject

* Fix next/config
2019-04-16 22:56:34 +09:00
JJ Kasper
6f9c3aa839 Remove experimental amp config (#7046)
This just removes the need for setting the experimental amp option
2019-04-16 22:09:57 +09:00
Joe Haddad
8b136a6f9d
Add experimental option to enable terser loader (#7033) 2019-04-15 20:00:01 +09:00
JJ Kasper
cf889d6094 Re-add experimental amp config (#7030)
* Update amphtml and canonical rels, put amp behind
experimental flag again, and update checking for amp query

* Fix typescript error

* Re-add flag to next.config.js
2019-04-15 18:26:23 +09:00
Joe Haddad
74cb4f4b7b
Switch to using .next/cache for flying shuttle and terser (#7013) 2019-04-11 17:09:12 -04:00
JJ Kasper
e5111745b5
Replace .amp.js with withAmp(Comp) (#7009)
* Add WithAmp to enable AMP support for
pages instead of .amp.js

* Update handling for exporting AMP

* Fix ampPath in export for / path and
revert isAmp logic to handle right

* Update amphtml test suite

* Add handling for noDirtyAmp during
export and update amp-export test suite

* Update serverless and export-default-map
test suites

* Update require-page tests
2019-04-11 13:59:26 -05:00
Joe Haddad
cc09478a7b Disable terser on .min.js input files (#7008)
This skips re-compressing already minified files.
2019-04-11 17:33:30 +02:00
JJ Kasper
4b9b2fb3a5 Make async-to-promises babel plugin experimental (#7006)
* Make async-to-promises babel plugin experimental

* Move excludes for asyncToPromises behind flag too

* Move other configs behind flag

* Re-add original exclude item
2019-04-11 10:28:57 -04:00
JJ Kasper
9e6708d144 Set custom cacheIdentifier for babel-loader (#6982)
* Set custom cacheIdentifier for babel-
loader that we can increment

* Update to consider external babel config
for cacheIdentifier

* Update to follow babel loader's cacheIdentifier behavior
2019-04-10 23:50:07 -04:00
JJ Kasper
711d45b698 Use next.config env and packages to calculate hashes (#7001)
* Use next.config env and packages to calculate
hashes for chunk-graph

* Remove example from testing

* remove left over import

* Tweak behavior
2019-04-10 15:19:50 -04:00
Joe Haddad
c2d0a4ef0e
Add Flying Shuttle v1 (#6991)
* Add Flying Shuttle v1

* Add serverless file restoration

* Add another message

* Update test

* Resolve page version last

* Print number of changed pages

* Remove old tests

* Re-add head build ID writing

* Change syntax appearance

* Start adding test components

* Fix react loadable manifest

* Complicate dynamic testing

* Fix first build missing head build id

* Remove flying shuttle tests
2019-04-10 12:41:59 -04:00
Joe Haddad
65fcf351c3
Add new getFileForPage helper to build utils (#6999) 2019-04-10 12:37:30 -04:00
Joe Haddad
a44788fb26
Disable flying shuttle when building for now dev (#6998) 2019-04-10 12:37:13 -04:00
Joe Haddad
a1598b5285
Disable recordsPath for selective page building (#6997)
We cannot rely on `recordsPath` when using selective page mode. All modules must be identified.
2019-04-10 12:23:16 -04:00
Joe Haddad
59fb471bc6
Correct page search order (#6996)
This fixes a case where a user has a page named `next.js.js` and `next.js`.
2019-04-10 12:22:10 -04:00
Joe Haddad
0e68d3c2d9
Adjust all modules identified plugin output (#6995)
This output clashed with the new output style. This output is more inline with existing behavior.
2019-04-10 12:21:14 -04:00
Joe Haddad
c2c634caa6
Use chunkGroup request over rawRequest for loadable manifest (#6993) 2019-04-10 12:06:16 -04:00
Joe Haddad
a863a720ef
Fix Chunk Graph Plugin hashes type (#6994) 2019-04-10 11:59:46 -04:00
Joe Haddad
94b8bf75e2
Move build utils to their own file (#6990)
* Move build utils to their own file

* Tweak feature detection
2019-04-09 23:15:35 -04:00
Joe Haddad
b543071440
Remove CLI and negative page building (#6986)
* Remove CLI and negative page building

* Remove select all tests

* Update test of getSpecifiedPages

* Prune old tests from snapshot

* Remove old flying shuttle tests
2019-04-09 22:57:46 -04:00
Joe Haddad
1810cf5abe
Add an experimental mode for flyingShuttle (#6985) 2019-04-09 22:05:40 -04:00
Luis Fernando Alvarez D
a5ad06f99b
the externals option is undefined for client builds (#6983) 2019-04-09 19:10:18 -05:00
Joe Haddad
ca565fc6e4
Adjust flying shuttle minify (#6980)
* Disable Terser plugin when using flying shuttle

* Add a new minify loader

* Downgrade terser

* Turn on minify loader

* Only compress source / mangle output
2019-04-09 15:13:25 -04:00
JJ Kasper
f04bd8bf33 Fix getSpecifiedPages on Windows (#6977)
weren't using the right separator
2019-04-09 15:10:08 -04:00
Luis Fernando Alvarez D
653f0a2a88 Disabled the checkWasmTypes config in webpack (#6978)
* Disabled the checkWasmTypes config in webpack

* Typescripted
2019-04-09 15:09:20 -04:00
Luis Fernando Alvarez D
ae5eeb39f4 Brought escape-string-regexp source to next (#6979)
* Brought escape-string-regexp source to next

* Added Copyright comment
2019-04-09 15:06:55 -04:00
Luis Fernando Alvarez D
72a31cb438
Disabled performance config in webpack (#6976) 2019-04-09 12:43:24 -05:00
Justin Chase
52dd42a6bb Do not clear the console (#6758)
* Do not clear the console

Its rude to clear the console, you may be sharing output with other processes even in tty mode.

* Remove unused dependency

* Dedupe and cleanup dev output without clearing

* use logError

* Remove exit handler

* Add next helper

* Add log helpers

* Switch store to log helpers and a shallow object compare

* Update other files to use new logging utility

* request => build

* Update ready on messages

* Use case insensitive matching
2019-04-09 11:52:03 -04:00
Luis Fernando Alvarez D
75a6ef0646 Moved NODE_ENV to our config (#6965)
Closes #6943
2019-04-09 15:16:27 +02:00
Luis Fernando Alvarez D
f89bd8237b Replace imurmurhash with string-hash (#6964)
Closes #6939
2019-04-09 12:49:30 +02:00
Tim Neutkens
35bbe30912
Optimize resolve configuration (#6954)
* Resolve Next.js loaders first

Next.js loaders should be resolved first, then node_modules. There is no need for NEXT_PROJECT_ROOT_NODE_MODULES anymore since all our loaders are internal

* Move wasm to end of array

Since wasm isn’t the main target for Next.js it makes no sense to try and resolve it as the first value, as it would incur a file not found for nearly all files in the compilation
2019-04-08 14:57:21 +02:00
Tim Neutkens
4b7dd25328
Simplify options assignment (#6949) 2019-04-08 14:54:28 +02:00
Tim Neutkens
7b64381151
Disable terser for server build (#6951)
Checking the stats first. But at least until https://github.com/zeit/next.js/issues/6950 is figured out we should disable it for serverless builds as it's also disabled for zeit.co serverless builds.
2019-04-08 14:06:04 +02:00
Tim Neutkens
da02f57054
use var as libraryTarget (#6945)
By using `var` we opt-out of the LibraryTemplatePlugin. Considering we have our own loader for registering pages this makes sense.
2019-04-08 11:14:51 +02:00
Tim Neutkens
45c100bc2a
Add babel-plugin-transform-async-to-promises (#6929)
* Add babel-plugin-transform-async-to-promises

* Remove unit test as this is covered by integration tests
2019-04-07 21:00:48 +02:00
Joe Haddad
444be1cba6
Fix nesting level of client page scripts (#6925) 2019-04-06 23:33:31 -04:00
Joe Haddad
c56e962918
Add lambda version of shared chunks (#6924)
* Add lambda version of shared chunks

* Fix test on Windows
2019-04-06 22:25:38 -04:00
Joe Haddad
33d32eab5a
Make chunk graph more accurate (#6923)
* Make chunk graph more accurate

* Include shared files in every page
2019-04-06 21:07:32 -04:00
Joe Haddad
a67b6ee117 Fix page resolution (#6920)
Previously this didn't work properly with nested pages.
2019-04-06 20:47:54 +02:00
Joe Haddad
e89c22a3d3
Add a build all but specified pages mode (#6916)
* Add a build all but specified pages mode

* Always include reserved pages in build

* Add tests for ignore pages
2019-04-06 13:11:38 -04:00
Joe Haddad
1603b202e8
Better debug build message (#6915)
* Output a more correct message for debug builds

* Adjust wording
2019-04-05 22:46:35 -04:00
Joe Haddad
bbfc0f8207
Add more chunk graph data (#6911)
* Fix nested position

* Drop front commit

* Emit new page chunks key with all involved files for a page
2019-04-05 16:25:24 -04:00
Joe Haddad
bb4ecfb639 Revert "Extract styled-jsx (#6901)" (#6907)
This reverts commit 5dc9f55e94.
2019-04-05 17:13:06 +02:00
Joe Haddad
3e5adfee24
Turn off module opts when selective page building (#6903) 2019-04-05 00:29:10 -04:00
Joe Haddad
5dc9f55e94
Extract styled-jsx (#6901) 2019-04-04 21:59:49 -04:00
Joe Haddad
e7ca6aa45e
Correctly compute unknown module ids (#6898) 2019-04-04 20:41:07 -04:00
Joe Haddad
cd9a108551
Add ** experimental page globbing support (#6899)
* Add ** page globbing support

* Update check
2019-04-04 20:19:58 -04:00
Joe Haddad
30fe5fc16d
Compute Chunk Graph file hashes on emit (#6897)
* Compute hashes of files during emit

* Fix tests

* Remove test from old location

* Correct the target
2019-04-04 18:00:04 -04:00
Joe Haddad
19c635175b
Make Client request BUILD_ID from the Server (#6891)
* Generate two versions of pages

* Add code VSCode deleted

* Add dynamicBuildId option to __NEXT_DATA__

* Reduce amount of diff

* Make getPageFile code easier to read

* Minimize diff

* minimize diff

* Fix default value for dynamicBuildId

* Fix weird bug

* Fetch the head build id on client

* Move __selectivePageBuilding

* Add tests

* Remove _this

* Add console warning
2019-04-04 17:54:01 -04:00
Connor Davis
899f21ff9b
Dont prefetch with debug mode (#6895) 2019-04-04 15:17:00 -05:00
JJ Kasper
8e51c78ed5
Add test for AMP in serverless mode (#6894)
* Add amp request header and check for amp
query in serverless mode

* Add serverless test for an AMP page

* Update to handle querystring weirdness

* Update serverless test config
2019-04-04 14:55:47 -05:00
JJ Kasper
7f096d0f46
Add check for data in serverless-loader (#6893) 2019-04-04 12:48:05 -05:00
Joe Haddad
ba09c5948e
Set buildId to a fixed value during debug build (#6886)
* Set buildId to a fixed value during debug build

* __debug => debug
2019-04-03 19:43:48 -04:00
JJ Kasper
a361a6a4a2
Fix serverless options (#6884) 2019-04-03 16:42:12 -05:00
Joe Haddad
d653216208
Add an experimental debug mode to builds (#6870)
* Add a debug mode to webpack configuration

* Undo debug change for dist dir
2019-04-02 21:19:08 -04:00
Joe Haddad
a63a493346
Refine selective page building (#6866) 2019-04-02 20:22:04 -04:00
JJ Kasper
aac50e4501
Add error message for AMP bind syntax (#6865)
* Add error message for AMP bind syntax

* Fix custom AMP scripts getting dropped

* Add data.js to package.json to include it
in releases
2019-04-02 17:32:07 -05:00
Joe Haddad
4201fb957d
Emit manifest of all page files (#6853)
* Get all modules included in build

* Add tests

* Get all modules contained per entry chunk

* Sort files

* Add specialized page entry to manifest

* Split manifest into pages and chunks key

* Update test

* Use relative paths to build directory

* Update test
2019-04-02 15:48:05 -04:00
JJ Kasper
6344c5f0c1
Add optimizing AMP pages (#6835)
* Added amp-toolbox-optimizer and added
optimizing AMP pages as dirty and clean

* Fix amp-optimizer breaking serverless build

* Exclude amp-toolbox-optimizer from serverless build

* Added check to make sure hybrid AMP pages
optimize cleanly during export

* Add check to make sure noDirtyAmp is applied
2019-04-02 13:01:34 -05:00
Tim Neutkens
b1fdffec75
amp-bind data injection (#6840) 2019-04-02 16:09:34 +02:00
Dylan Brookes
035890f9cd Fix adblock comment (#6859) 2019-04-02 04:37:04 -04:00
Shahzeb K
25deefbba7 Avoid "ad" anywhere in the buildId (#6854)
* Added a check for ad_ in the buildId

* ad_ > ad

Co-Authored-By: lfades <luis@zeit.co>

* Update the `ad` comment

Co-Authored-By: lfades <luis@zeit.co>

* Avoid all buildId's that contain "ad"

Looking through the uBlock Origin filter list, it uses regex wildcards to avoid various things with "ad" anywhere in the string. It's a safe bet to just avoid "ad" all together (as opposed to just at the start).

* Use regex (case incensitive) to check for "ad" 

The following cases will set this regex to true:

```
/ad/i.test("somead")
/ad/i.test("someADlksdjf")
/ad/i.test("adlksdjf")
/ad/i.test("ADlksdjf")
```
2019-04-01 20:40:43 -04:00
Luis Fernando Alvarez D
742f29fba5 buildId is not an ad (#6851)
* Added a check for ad_ in the buildId

* ad_ > ad

Co-Authored-By: lfades <luis@zeit.co>

* Update the `ad` comment

Co-Authored-By: lfades <luis@zeit.co>
2019-04-01 15:22:21 -04:00
Luis Fernando Alvarez D
c864ab9324 Added useBuiltIns to babel object-rest-spread (#6805)
Use `Object.assign` for the rest-spread transform.
2019-03-31 17:30:25 +02:00
Luis Fernando Alvarez D
6bb83272a3 Exclude transform-typeof-symbol (#6812)
Related to [create-react-app#5278](https://github.com/facebook/create-react-app/pull/5278#issue-220142150)
2019-03-30 01:54:05 +01:00
Luis Fernando Alvarez D
f81e5f4cad Added babel-plugin-dynamic-import-node (#6811)
Replaces `import()` with `require` only for the testing environment.
2019-03-30 01:50:24 +01:00
Joe Haddad
b871e43601
Add a leading slash to passed pages (#6808) 2019-03-27 15:21:30 -04:00
Joe Haddad
b835e2589d
Specified page builds (#6796)
* [wip] individual page builds

* Make flag experimental and remove from main bin

* Do not split chunks when using shared runtime
2019-03-27 11:51:05 -04:00
Luis Fernando Alvarez D
da9472246c Remove prop-types import in the build (#6798)
Tests don't catch this change because `isProduction &&` is always false so I tested it with a local build
2019-03-27 12:26:01 +01:00
JJ Kasper
244b0e700e
Add AMP validation on export (#6794)
* Add err.sh link and pool validation results
to wait to show error until export is finished

* Fix wording in amp-export-validation err.sh

* Update validation error message

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>

* Update ways to fix text

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>

* Update why the error occurred wording

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>

* Update wording some more

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
2019-03-26 16:21:27 -05:00
Joe Haddad
0249b331c2
Use a shared module cache (#6791)
* [WIP] Use a shared module cache

* ID modules in development

* Revert "ID modules in development"

This reverts commit 0613d92fa2c8c7fa11a5ff5b7770d784af1cec63.

* Remove context replacement

* Only enable shared runtime in prod

* Sort settings

* Add shared runtime experimental setting

* only enable shared runtime in serverless
2019-03-26 12:30:31 -04:00
Joe Haddad
8c175e5daa Replace buildId well known string during output (#6782)
* Replace buildId well known string during output

* Fix linting
2019-03-25 17:06:00 +01:00
Tim Neutkens
907dd27a88
Make main.js override work correctly (#6781) 2019-03-25 15:08:02 +01:00
Connor Davis
a79c004de0 Remove magic-string (#6772)
* Remove magic-string

* Add back input

* change if statement back

* Fix typo

* remomve useless import
2019-03-24 23:50:58 -04:00
Tim Neutkens
3e7b932b2b
ncc resolve and arg (#6771)
More modules to follow.
2019-03-24 23:38:03 +01:00
Tim Neutkens
f639becf88
Don't use array for main chunk (#6767)
* Simplify getDisplayName

* Don’t use array for single file

* Add aliases, drop htmlescape as it’s not longer in the codebase

* Add correct path

* Use the correct router

* Remove dynamic for now

* Mark as external as the modules are directly called

* Add comment explaining what this does
2019-03-24 14:33:10 +01:00
Tim Neutkens
a8d08d3920
ncc nanoid (#6768) 2019-03-24 14:21:30 +01:00
Tim Neutkens
eb28d4cdcf
Remove hoist-non-react-statics from with-router (#6765)
* Remove hoist-non-react-statics from with-router

* Drop hoist-non-react-statics from package.json
2019-03-23 21:31:44 +01:00
Tim Neutkens
6716bcbf87
Remove error-debug.js checks as the chunk is removed (#6761)
This code is obsolete as the chunk was removed.
2019-03-23 16:55:44 +01:00
Tim Neutkens
d24af62140
Make pages-manifest-plugin compatible with webpack 5 (#6760)
Apparently `entries` is removed in webpack 5, using `chunks` instead which holds the same result.
2019-03-23 15:33:13 +01:00
Joe Haddad
78bcfa07b2 Skip console clearing when not in a TTY (#6726) 2019-03-19 23:16:02 +01:00
Joe Haddad
ff5c8465de
First pass of runtime amp validator (#6708) 2019-03-18 19:21:18 -04:00
Tim Neutkens
6104a71afb Make react-loadable-manifest only have modules that are part of dynamic chunks (#6622)
* Make react-loadable-manifest only have modules that are part of dynamic chunks

* Add manifest sorting
2019-03-17 14:19:26 -04:00
JJ Kasper
11a161f296 Add possible explanation for webpack resolve error (#6682)
When overriding `config.resolve.alias` incorrectly webpack will throw an error because private-next-pages is not defined. This adds a more descriptive error explaining the error better.

Fixes: #6681
2019-03-17 13:13:29 +01:00
JJ Kasper
a6ddaefe22 Add experimental exportTrailingSlash config (#6664)
By default when `next export`ing a Next.js application we will automatically append a `/` to all urls to be fully compatible with the directory structure being output.

However since most platforms support directory indexes it makes sense to change this default in the future.

This PR adds `exportTrailingSlash` as experimental flag. We'll try this out for a bit on nextjs.org / zeit.co/docs before introducing it as new option.

The default value is `true` as this is the current behavior in stable Next.js.

```
{
  experimental: {
    exportTrailingSlash: false
  }
}
```

⚠️ as with all experimental flags being added this is subject to breaking between canary/stable versions.
2019-03-17 00:54:58 +01:00
JJ Kasper
c81bd27587 Fix relative next path not working in webpack config (#6667)
* Fix relative next path not working in
webpack config

* Also add relative fix to amp path
2019-03-15 00:09:00 -04:00
Joe Haddad
d7ab018f31
Hash module IDs to save on bundle size (#6660) 2019-03-15 00:08:22 -04:00
Joe Haddad
0ae34c9a9d
Use relative instead of absolute for entry paths (#6659) 2019-03-14 21:45:50 -04:00
Joe Haddad
6902afbd3f
Stabilize Chunk ID generation (#6663)
* Add a new field to webpack types

* Revert "Add a new field to webpack types"

This reverts commit d35fa02207fbfd0085da0fc56aac42c4ff7c34c9.

* Add HashedChunkIdsPlugin to make consistent chunk ids

* Revert "Revert "Add a new field to webpack types""

This reverts commit 338219049e1432038f90c91928b010bbb1267999.

* Make it optional

* Remove record ids

* Revert "Remove record ids"

This reverts commit 15c22dbcda72466c382397c91d02295620f62326.
2019-03-14 21:38:57 -04:00
Connor Davis
b73abc0a4b Delete using realpath in HMR cache (#6635)
This will allow symlinked assets to be removed from the cache as well

Fixes: #5620
2019-03-15 00:22:57 +01:00
Joe Haddad
1fb1b75216
Ensure all modules are identified (#6656)
* Ensure all modules are identified

* Extend a webpack Plugin

Co-Authored-By: Timer <timer150@gmail.com>
2019-03-14 11:04:08 -04:00
Joe Haddad
e5636dcdb0
Inject the build ID after webpack runs (#6618)
* Inject the build ID after webpack runs

* add webpack sources types

* use webpack plugin instead

* reset file

* Skip source maps if none were provided

Co-Authored-By: Timer <timer150@gmail.com>
2019-03-12 16:39:44 -04:00
Tim Neutkens
8cf6ef58f0
Remove unused dev option from babel-loader (#6624) 2019-03-12 15:19:08 +01:00
Joe Haddad
2e32aa8630
Ensure correct key order (#6616)
* Ensure correct key order

* Fix bug

* Format this document while we're at it
2019-03-12 00:01:50 -04:00
JJ Kasper
179d09e8e0
Remove cacheKeys in favor of simply a cacheKey (#6613) 2019-03-11 22:32:26 -05:00
Joe Haddad
f6b7503e55
Sort pages between bundles (#6612) 2019-03-11 17:34:41 -04:00
JJ Kasper
995460d7dd
Replace md4 hashing with murmurhash (#6611) 2019-03-11 16:23:04 -05:00
JJ Kasper
eb0e83cea3 Remove cacache (#6610) 2019-03-11 16:24:07 -04:00
Tim Neutkens
b32e65a830 Add experimental profiling flag (#6594)
* Add experimental profiling flag

* Update config.js
2019-03-11 13:53:24 -04:00
JJ Kasper
852a62bf56 Add experimental cpus config and use CircleCI env var (#6604)
* Add using CircleCI env var for max workers
and expose webpack to config

* Expose experimental cpu config

* Fix typo

* Remove log
2019-03-11 17:33:30 +01:00
Joe Haddad
041be6f4aa Disable webpack minifier (#6603)
When the webpack `mode` is set to `production`, `minimizer: undefined` means "use the default webpack minifier."

We need to explicitly disable the webpack minifier via `minimize: false`. This should speed up non-serverless builds. 😄 

This doesn't affect dev, but I added the toggle there for consistency.
2019-03-11 15:51:23 +01:00
Tim Neutkens
557fc95910
Don't use webpack multiCompiler for single configuration (#6598)
When compiling the serverless target there is no need for having an array of configs.
2019-03-10 15:46:50 +01:00
Tim Neutkens
8ffcb3f3e7 Don’t load dev plugins for production bootup (#6589)
* Don’t load autodll-webpack-plugin for production bootup

* Only require autodll when client-side compilation is ran

* Try to fix build
2019-03-09 23:27:33 -05:00
Tim Neutkens
e8095c0e2e Remove cjs file (#6590) 2019-03-09 22:34:27 -05:00
Tim Neutkens
dd60199cec
Remove case-sensitive-paths-plugin (#6587)
While this is a nice feature it does filesystem operations to check if the resolved file matches the filesystem.
2019-03-10 01:44:51 +01:00
Connor Davis
f8be040c79 Next minifier cache (#6582)
Changes the name of the cache folder so we can predictably cache on Now
2019-03-09 09:09:44 +01:00
Tim Neutkens
d3e92cceec
Remove more terser-webpack-plugin code (#6575) 2019-03-08 16:26:20 +01:00
Tim Neutkens
3f9a44996a
Remove more terser code (#6564)
* Remove chunkfilter and extractcomments options as they’re unused

* Remove unused variable

* Remove cacheKeys option, improve filter

* Remove more terser code

* Remove unused variable
2019-03-07 19:45:49 +01:00
k-kawakami
d9060f5abd Remove trailing spaces (#6547)
### changes
#### remove trailing spaces

When I was using example I noticed trailing spaces.
So, this PR removes the trailing spaces of json file, README, and others.

`examples/with-jest-typescript/src/modules/cars/Overview.tsx` also has it, but this time it did not change as tslint error occurs at commit.
2019-03-07 17:40:08 +01:00
Tim Neutkens
9b62f208bb
Remove cacheKeys option and improve filtering (#6559)
More cleanup of terser-plugin.
2019-03-07 14:28:32 +01:00
Tim Neutkens
abad29b413
Remove chunkfilter and extractcomments options as they’re unused (#6549)
Remove some obsolete code paths.
2019-03-06 21:28:42 +01:00
Tim Neutkens
0088083f52
Check if esmodules is supported before enabling useESModules (#6534)
* Check if esmodules is supported before enabling useESModules

* Remove console.log
2019-03-05 16:57:07 +01:00
JJ Kasper
c3b1f31ed5 Fix /index/index.js route not emitting the right route in production (#6516)
Also added integration test in production for this

Fixes: #6285
2019-03-03 19:36:32 +01:00
JJ Kasper
5034e4e1de
Updated entries to not output _app and _document in serverless (#6512)
* Updated entries to not output _app and _document in serverless

* Add test
2019-03-02 13:53:13 -06:00
JJ Kasper
a9c398854a
Add console.error before exit on uncaughtException (#6504) 2019-03-01 13:18:33 -06:00
Tim Neutkens
8eb813a640
await config (#6488)
* await config

* update config-promise-error test

* Actually update test
2019-03-01 01:09:07 +01:00
Joe Haddad
330bedacc7 Add Babel plugin that fixes className for Amp elements (#6486)
This is a simple Babel plugin that overwrites certain attributes for `amp-` elements.
2019-02-28 23:04:29 +01:00
JJ Kasper
8ae1cd35bd Fix dynamic require breaking after updating to v8 (#6475)
* Fix dynamic require breaking after updating to v8

* Add test for dynamic require
2019-02-28 14:41:54 +01:00
JJ Kasper
1c1d5d01f8 Throw error when Promise is returned in next.config (#6476)
After discussion, it was decided we should throw an error when a promise is returned in `next.config.js` as this isn't supported

Fixes: #6416
2019-02-28 14:39:51 +01:00
Joe Haddad
41eaa9cf5a
Run ncc on unistore to fix install warning (#6459)
ncc unistore to fix install warning
2019-02-27 09:12:40 -05:00
JJ Kasper
256970ac75 Remove next-to-next-server babel plugin (#6458)
After discussion it was decided instead of rewriting `next/config` and `next/head` imports to `next-server/config` and `next-server/head` we should just allow importing them as `next/config` and `next/head`
 
Fixes: #6187
2019-02-27 11:00:02 +01:00
Connor Davis
5514949df0 Remove glob package (#6415)
We don't use a lot of the features of `glob`, so let's remove it in favor of a leaner approach using regex.

It's failing on windows and I have no idea why and don't own a windows machine 🤦🏼‍♂️

(Ignore some of the commits in here, I forgot to create the new branch before I started working)
2019-02-24 22:08:35 +01:00
Connor Davis
b146eb5200
Replace del with rimraf package (#6411) 2019-02-22 13:49:30 -06:00
Tim Neutkens
bfb5224ce4
Remove schema-utils dependency (#6413) 2019-02-22 20:05:34 +01:00
Tim Neutkens
9247c90177
Remove http-status dependency (#6405) 2019-02-22 16:25:11 +01:00
Tim Neutkens
d14d1704cb
Remove ansi-html dep (#6394)
It's not needed since we use react-error-overlay for webpack errors.
2019-02-22 00:12:47 +01:00
Joe Haddad
1757ad022c Drop cli-cursor dependency (#6387) 2019-02-21 15:34:35 +01:00
Joe Haddad
8b784766f1 Remove alternate screen usage (#6377)
* Make console output well behaved

* Fix bad rebase
2019-02-21 00:42:27 +01:00
Connor Davis
61de215e04
Move webpack config to TypeScript (#6348) 2019-02-20 13:24:02 -06:00
Joe Haddad
90f9c64b74
Use alternate screen buffer if terminal supports it (#6364) 2019-02-20 07:20:09 -05:00
wtgtybhertgeghgtwtg
ddd01df4ec Make getBaseWebpackConfig synchronous. (#6356)
Currently, `getBaseWebpackConfig` is marked async, but it doesn't await anything or otherwise return a Promise.  Please correct me if I am wrong, but it looks like it can be made synchronous.
2019-02-20 00:05:46 +01:00
Connor Davis
fcf1167cd4 Upgrade standard and fix files (#6358)
Upgrades `standard` to major version 12
2019-02-19 22:45:07 +01:00
Joe Haddad
7078f6567d Make build output friendlier (#6320)
Success:
![image](https://user-images.githubusercontent.com/616428/52907314-5e636480-322d-11e9-9420-b348663a3a7a.png)

Error:
![image](https://user-images.githubusercontent.com/616428/52907318-6c18ea00-322d-11e9-848d-e615d6af747d.png)

Warnings:
![image](https://user-images.githubusercontent.com/616428/52907353-2d376400-322e-11e9-9778-370f36912491.png)

---

We can still make build error output friendlier, but this is a good start.
2019-02-17 12:56:48 +01:00
Joe Haddad
56b1f81ace Fix development mode output (#6312)
* Remove usage of WebpackBar and Friendly Errors

* Add new clearConsole helper

* Add new simplified output for development mode

* Add an explicit bootstrapping mode

* Add missing returns

* Use existing output style

* Adjust first output to say Waiting on

* Only print URL if present
2019-02-16 17:09:49 +01:00
Connor Davis
1e5d0908d0 Block Certain Env Keys That Are Used Internally (#6260)
Closes: #6244 

This will block the following keys:
```
NODE_.+
__.+
```

There doesn't seem to be a way to simulate a failed build or else I'd add tests for it.
2019-02-15 17:49:40 +01:00
Joe Haddad
33b9ebc783 Add module as server fallback main field (#6256)
* Add `module` as server fallback main field

* Test that a module only package can be imported
2019-02-12 01:39:57 +01:00
Jason Miller
734513b9be Apply babel to .mjs files (#6253) 2019-02-11 18:59:24 +01:00
Akram
63c25a9c60 update preset.ts to use isProduction variable (#6234) 2019-02-10 18:45:51 +01:00
Tim Neutkens
45f5663558
Bring in terser-webpack-plugin (#6231)
* Bring in terser-webpack-plugin

* Ignore terser from linting
2019-02-10 04:55:09 +01:00
Connor Davis
6f162b94e1 Add Error when using publicRuntimeConfig with target serverless and add buildVars (#6212)
Introduce env to next.config.js for build-time configuration
2019-02-08 14:38:18 +01:00
Tim Neutkens
59280f7747
Compile all next module files (#6155) 2019-01-27 21:56:02 +01:00
Tim Neutkens
b4ade0a3cd Revert "Move phases back to next/constants (#6104)"
This reverts commit 9112f63eba.
2019-01-26 02:01:49 +01:00
Luc
14604450cb Print list of pages when building (#6125)
* show pages created when building

* fix types
2019-01-25 18:36:29 +01:00
Tim Neutkens
7ecf675834
Remove resolve rule (#6133)
Fixes #6117

I'm not entirely sure why we had this rule in the first place. I think for some tests related things when we didn't have a monorepo yet. However it could also be related to bundle sizes. I'll compare that when the build finishes.

The reason for #6117 is that we added `react-is` to the dependency tree of Next.js to check valid elements. react-redux uses hoist-non-react-statics which ships a different version of react-is in this case, one that has `ReactIs.isMemo`
2019-01-25 18:33:58 +01:00
Tim Neutkens
243cd65c1d
Drop assetSizePlugin (#6122)
Fixes #6121
2019-01-24 23:04:20 +01:00
Connor Davis
f28833c594 Upgrade Webpack to 4.29.0 with FutureEmitAssets for Massive Memory Optimizations (#6114)
We want our new memory optimizations (https://github.com/webpack/webpack/pull/8609)
2019-01-24 10:25:58 +01:00
Tim Neutkens
9112f63eba
Move phases back to next/constants (#6104)
* Move phases back to next/constants

* Fix typescript error
2019-01-23 14:10:12 +01:00
Connor Davis
8065130343 Use webpack IgnorePlugin to exclude 'react-is' from production build (#6084)
`react-is` isn't used in production, so we shouldn't bundle it.

Note: most of those plugins are using the `dev` variable, but in case someone runs `NODE_ENV=development next build`, they would need a copy of `react-is` because the conditional use of `react-is` checks `NODE_ENV` — not whether or not HMR is being used (what what the `dev` variable is based on).
2019-01-18 12:12:29 +01:00
Telegin Evgeniy
aa474017d7 Add iOS 10 support for TerserPlugin (#6067)
Resolves #5630
2019-01-16 10:32:47 +01:00
Tim Neutkens
da3c3aded1
Use Object.assign instead of object spread for serverless loader (#6056)
Fixes https://github.com/zeit/now-builders/issues/168

For some reason with a certain mix of deps `...` is not supported in webpack's parsing.
By default it is supported as all our tests passed before and we have deployed Next.js apps on v2 already.
2019-01-15 02:20:20 +01:00
Tim Neutkens
02ab732096
Remove next/asset (#6046)
* Remove next/asset

Reasoning described in #5970

* Remove next/asset tests

* Bring back asset-page
2019-01-14 01:32:20 +01:00
Connor Davis
1edd872f54
Only Minify Whitespace on Serverless Builds (#6037) 2019-01-11 17:15:12 -06:00
Tim Neutkens
2e9ff91372
Compile next/client and next/pages (#6019)
Because next-routes requires APIs outside of compilation we have to compile these

Fixes https://github.com/fridays/next-routes/issues/274
Fixes #6017
2019-01-11 22:26:27 +01:00
Tim Neutkens
ce3d1914fa
Disable assetSizePlugin in serverless target (#6028) 2019-01-10 23:01:30 +01:00
Tim Neutkens
b547d300d9
Show clear error when client build fails in serverless target (#6027) 2019-01-10 22:10:50 +01:00
Tim Neutkens
9ffd23eeef
Replace pages-plugin with loader (#5994)
* Remove unused argument

* Replace pages-plugin with loader

* Add loader-utils types

* Remove logs

* Bring back previous deposal behavior

* Remove console.log

* Remove webpack/utils as it’s no longer in use

* Remove hot-self-accept-loader

* Error Recovery tests

* Make hotSelfAccept a noop default loader

* Fix windows deleted/added

* Remove logging

* Remove unused variables

* Remove log

* Simplify entrypoint generation

* Don’t return the function

* Fix _app test

* Remove code that’s always true

* Move aliases to constants

* Use alias

* Join pages alias in reduce

* Default pages differently

* Loop over pages instead of manually defining

* Move entry generation into common function

* Update packages/next/build/webpack/loaders/next-client-pages-loader.ts

Co-Authored-By: timneutkens <tim@timneutkens.nl>

* Update packages/next/build/webpack/loaders/next-client-pages-loader.ts
2019-01-08 23:10:32 +01:00
Luc
ba95f7541c Improve assets size (#5999)
It looks like :

```
Pages sizes after gzip:

┌ / (196 B)
├ /_app (11.5 kB)
├ /_error (4.44 kB)
├ /blog (196 B)
└ /blog/page (195 B)
```

(style inspired from now-cli : https://github.com/zeit/now-cli/blob/canary/src/util/output/builds.js)

I'll add dynamic chunks in a separate PR.

@timneutkens Do you want to keep `_app` and `_error` or filter them out ? I think it's a good idea to keep them, because `_app` can get pretty large and it would encourage code splitting in that case.
2019-01-06 16:42:09 +01:00
Tim Neutkens
07c6e2852f
Export render instead of default for serverless target (#5979)
Extends on #5927, instead of `.default` we'll expose `.render` which is semantically more correct / mirrors the naming of the custom server API.

I've updated the spec in #5927 to reflect this change.

(copied from #5927):

```js
const http = require('http')
const page = require('./.next/serverless/about.js')
const server = new http.Server((req, res) => page.render(req, res))
server.listen(3000, () => console.log('Listening on http://localhost:3000'))
```
2019-01-02 14:59:28 +01:00
Tim Neutkens
0f23faf81f
Serverless Next.js (#5927)
**This does not change existing behavior.**

building to serverless is completely opt-in.

- Implements `target: 'serverless'` in `next.config.js`
- Removes `next build --lambdas` (was only available on next@canary so far)

This implements the concept of build targets. Currently there will be 2 build targets:

- server (This is the target that already existed / the default, no changes here)
- serverless (New target aimed at compiling pages to serverless handlers)

The serverless target will output a single file per `page` in the `pages` directory:

- `pages/index.js` => `.next/serverless/index.js`
- `pages/about.js` => `.next/serverless/about.js`

So what is inside `.next/serverless/about.js`? All the code needed to render that specific page. It has the Node.js `http.Server` request handler function signature:

```ts
(req: http.IncomingMessage, res: http.ServerResponse) => void
```

So how do you use it? Generally you **don't** want to use the below example, but for illustration purposes it's shown how the handler is called using a plain `http.Server`:

```js
const http = require('http')
// Note that `.default` is needed because the exported module is an esmodule
const handler = require('./.next/serverless/about.js').default
const server = new http.Server((req, res) => handler(req, res))
server.listen(3000, () => console.log('Listening on http://localhost:3000'))
```

Generally you'll upload this handler function to an external service like [Now v2](https://zeit.co/now-2), the `@now/next` builder will be updated to reflect these changes. This means that it'll be no longer neccesary for `@now/next` to do some of the guesswork in creating smaller handler functions. As Next.js will output the smallest possible serverless handler function automatically.

The function has 0 dependencies so no node_modules are required to run it, and is generally very small. 45Kb zipped is the baseline, but I'm sure we can make it even smaller in the future.

One important thing to note is that the function won't try to load `next.config.js`, so `publicRuntimeConfig` / `serverRuntimeConfig` are not supported. Reasons are outlined here: #5846

So to summarize:

- every page becomes a serverless function
- the serverless function has 0 dependencies (they're all inlined)
- "just" uses the `req` and `res` coming from Node.js
- opt-in using `target: 'serverless'` in `next.config.js`
- Does not load next.config.js when executing the function

TODO:

- [x] Compile next/dynamic / `import()` into the function file, so that no extra files have to be uploaded.
- [x] Setting `assetPrefix` at build time for serverless target
- [x] Support custom /_app
- [x] Support custom /_document
- [x] Support custom /_error
- [x] Add `next.config.js` property for `target`

Need discussion:
- [ ] Since the serverless target won't support `publicRuntimeConfig` / `serverRuntimeConfig` as they're runtime values. I think we should support build-time env var replacement with webpack.DefinePlugin or similar.
- [ ] Serving static files with the correct cache-control, as there is no static file serving in the serverless target
2018-12-28 11:39:12 +01:00
Tim Neutkens
059dd309c5
Make browser side resolve prefer mjs files (#5898) 2018-12-16 16:26:45 +01:00
Tim Neutkens
1464d932eb
Disable webpack cache option in prod (#5877)
* Disable webpack cache option in prod

* Remove cache option as it’s added by mode === ‘development’
2018-12-14 11:34:05 +01:00
Connor Davis
419bec0b9b Fix #5674 Append crossOrigin on the client side too, add config option for crossOrigin (#5873)
# Fixes https://github.com/zeit/next.js/issues/5674

This adds config option
```js
// next.config.js
module.exports = {
  crossOrigin: 'anonymous'
}
```
This config option is defined in the webpack Define Plugin at build.
`Head` and `NextScript` now use the config option, if it's not explicitly set on the element.
This value is now passed to Webpack so it can add it to scripts that it loads.
The value is now used in `PageLoader` (on the client) so it can add it to the scripts and links that it loads.
Using `<Head crossOrigin>` or `<NextScript crossOrigin>` is now deprecated.
2018-12-13 01:05:21 +01:00
Tim Neutkens
5708e99eca
Run compilers sequentially when in lambdas mode (#5862) 2018-12-11 21:46:23 +01:00
Oscar Busk
27c0b199d0 Fix paths when built on windows (#5795)
This PR Fixes #4920

So the problem is that when a next.js application is built on windows, the `pages-manifest.json` file is created with backslashes. If this built application is deployed to a linux hosting enviroment, the server will fail when trying to load the modules.

```
Error: Cannot find module '/user_code/next/server/bundles\pages\index.js
```

My simple solution is to modify the `pages-manifest.json` to always use linux separator (`/`), then also
modify `server/require.js` to, when requiring page, replace any separator (`\` or `/`) with current platform-specific file separator (`require('path').sep`).

The fix in `server/require.js` would be sufficient, but my opinion is that having some cross-platform consistency is nice.

This change was tested by bulding an application in windows and running it in linux and windows, aswell as building an application in linux and running it in linux and windows. The related tests was also run.
# Conflicts:
#	test/integration/production/test/index.test.js
2018-12-10 14:48:06 +01:00
Tim Neutkens
6729fa4580 Mark react/react-dom as external when in lambdas mode (#5828) 2018-12-05 13:40:17 -08:00
Tim Neutkens
dd556bf90b
Add tsc type checking (#5826)
* Add tsc type checking

* Add linting on circle

* Add node-fetch types

* Use strict mode
2018-12-05 21:45:50 +01:00
Tim Neutkens
1a5fc941ce Remove console.log after verifying the correct files are ignored 2018-12-05 15:05:14 +01:00
Tim Neutkens
6542750e12
Fix edge case where file had module.export in the content (#5823)
We ran into this eg on hyper-site, which has `module.exports` in the content.
2018-12-05 14:37:26 +01:00
Tim Neutkens
2d5b56a181 Disable usage of esmodules when commonjs is enabled on the preset 2018-12-04 20:10:22 +01:00
Tim Neutkens
d11a3aa34e
Add tests for isomorphic-unfetch bundling issue (#5805)
* Add tests for isomorphic-unfetch bundling issue

* Remove unneeded extra option

* Remove isomorphic-fetch
2018-12-04 10:59:12 +01:00
Tim Neutkens
f79230db33
Change module resolution extensions (#5801)
Same as https://github.com/zeit/ncc/pull/80
2018-12-03 19:36:24 +01:00
Tim Neutkens
58f5dd297a
Add Typescript types for builds functions (#5791) 2018-12-03 14:18:52 +01:00
Tim Neutkens
a9cf735f50
Convert babel plugins to typescript (#5789)
Slowly moving files over 💯
2018-12-02 18:30:00 +01:00
Tim Neutkens
e5002234d0
Transpile imports if module has module.exports (#5780)
Fixes #5778
Fixes #3650
2018-11-30 17:56:07 +01:00
Tim Neutkens
55e89e759a
Fix polyfill for ie11 (#5763)
* Fix polyfill for ie11

* Use esmodules only when using webpack
2018-11-29 12:36:03 +01:00
Tim Neutkens
fb92fdef54
Make sure const/async is transpiled (#5760)
* Make sure const/async is transpiled

* Use babel common compilation instead
2018-11-28 17:53:49 +01:00
Tim Neutkens
15bb1c5e79
Use Typescript to transpile Next.js core files instead of Babel (#5747)
- Replaces taskr-babel with taskr-typescript for the `next` package
- Makes sure Node 8+ is used, no unneeded transpilation
- Compile Next.js client side files through babel the same way pages are
- Compile Next.js client side files to esmodules, not commonjs, so that tree shaking works.
- Move error-debug.js out of next-server as it's only used/require in development
- Drop ansi-html as dependency from next-server
- Make next/link esmodule (for tree-shaking)
- Make next/router esmodule (for tree-shaking)
- add typescript compilation to next-server
- Remove last remains of Flow
- Move hoist-non-react-statics to next, out of next-server
- Move htmlescape to next, out of next-server
- Remove runtime-corejs2 from next-server
2018-11-28 15:03:02 +01:00
Tim Neutkens
08e3396574
Fix graphql issue with lambdas flag (#5755)
Fixes https://spectrum.chat/?t=604f6aa6-23f2-4358-8b0b-14e5810178dc
2018-11-27 22:20:13 +01:00
Richard Park
44d661af67 Upgrade to webpack@4.26 (#5729)
* Upgrade terser-webpack-plugin

* Upgrade webpack

* Extract common terserPluginConfig
2018-11-22 10:14:14 +01:00
Tim Neutkens
c2eaf26ea9
Remove flow types (#5704)
* Remove flow-typed

* Remove flow types

* Remove the last types

* Bring back taskr dependency

* Revert "Bring back taskr dependency"

This reverts commit 38cb95d7274d63fe63c6ac3c95ca358a28c17895.

* Bring back preset-flow as it’s used for tests

* Revert "Revert "Bring back taskr dependency""

This reverts commit b4c933ef133f4039f544fb10bf31d5c95d3b27a2.
2018-11-21 16:04:37 +01:00
Tim Neutkens
70cae4b2ea
Disable mjs support when in lambdas mode (#5712) 2018-11-20 12:13:31 +01:00
Tim Neutkens
7d78c3b641 Add node_modules bundling under the --lambdas flag for next build (#5690)
* Add node_modules bundling under the —lambdas flag for next build

* Run minifier when lambdas mode is enabled

* Add lambdas option to next.config.js

* Add test for lambdas option
2018-11-17 11:15:33 -08:00
Luc
add5879cc2 Print assets sizes after build (#5664)
It looks like this : 

![capture d ecran 2018-11-13 a 00 47 12](https://user-images.githubusercontent.com/6616955/48361936-7cc13d80-e6dd-11e8-8aa8-c5a73beae966.png)

I'm not sure about the License part, can you check @timneutkens ?
2018-11-13 10:46:26 +01:00
Tim Neutkens
d0dd1bc28d
Trim buildId returned from generateBuildId (#5634)
* Trim buildId returned from generateBuildId

* Pass dir to function
2018-11-12 15:57:48 +01:00
Tim Neutkens
a0137d4fd8 Rename class to NextJsRequireCacheHotReloader 2018-11-07 18:56:53 +01:00
Tim Neutkens
d6284f171b
Don’t fail build on webpack warning (#5622) 2018-11-07 18:38:37 +01:00
Tim Neutkens
2e14b4491b
Bundle @babel/runtime into server bundle (#5619) 2018-11-07 15:38:35 +01:00
Tim Neutkens
f01457e8fc
Take full advantage of caching between builds (#5597)
Takes advantage of caching between builds for Terser, also makes writing caches for babel-loader faster by disabling compression.

Results for zeit.co (350 pages):

Without cache:
[4:16:22 PM] Compiled server in 1m
[4:16:57 PM] Compiled client in 2m
  Done in 125.83s.

With cache:
[4:19:38 PM] Compiled client in 17s
[4:19:50 PM] Compiled server in 29s
  Done in 31.79s.

Note: these results are from my multi-core Macbook Pro 2017, exact specs:
MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
- 3,3 GHz Intel Core i5
- 16 GB 2133 MHz LPDDR3
- Intel Iris Plus Graphics 650 1536 MB

The `without cache` build runs uglify in parallel, so without cache is likely to take longer on environments where you have only 1 core available.

The `with cache` build however runs in a single thread, so the results should be similar.
2018-11-05 17:51:56 +01:00
Tim Neutkens
1aaa288759 Remove console.log 2018-11-05 01:49:12 +01:00
Tim Neutkens
4945740ac7 Add dir and distDir to resolve log 2018-11-05 00:02:21 +01:00
Tim Neutkens
1388c6897e Add resolve_config log 2018-11-04 23:42:46 +01:00
Tim Neutkens
d5caafb86e Log original error 2018-11-04 23:04:54 +01:00
Tim Neutkens
771e494a88 Log out stats.errors and err object when build fails 2018-11-04 22:16:24 +01:00
Tim Neutkens
b04923775b Add string-hash to compilation for styled-jsx 2018-11-04 03:26:52 +01:00
Tim Neutkens
15854f515b
Transpile styled-jsx into server bundle (#5588)
Drops an additional 6MB from the next-server node_modules size as there's no lodash
2018-11-04 01:11:40 +01:00
Tim Neutkens
a2553bb46e
Remove registration code from initial markup (#5583)
Clears the way a bit for #4943, also makes _document.js less complex, and will allow us to move `__NEXT_DATA__` to a `application/json` script tag.

Also this causes a slightly smaller bundle size 😌
2018-11-03 01:59:54 +01:00
Robert Sköld
123b46634a Moved nanoid use from next-server to next/build (#5441) 2018-11-02 23:19:48 +01:00
Radovan Šmitala
bf157015fb Remove WriteFilePlugin (#5541)
It is native by webpack-dev-middleware 3.1.0 up
2018-11-02 19:47:56 +01:00
Timmy Willison
1b8f56556b Output warnings and errors from webpack individually (#5442)
- Shows warnings even when resolving, to facilitate hints set to 'warning'
- Fixes #876 : Set performance.hints to 'warning' or 'error' in next.config.js
2018-10-20 17:02:20 +02:00
Vasyl Berezovyy
9a09de2feb Remove ignore plugin from webpack build flow (#5394) 2018-10-20 16:59:43 +02:00
Shu Ding
409cf71a4d Move styled-jsx to external modules (#5403) 2018-10-08 16:26:05 +02:00
Tim Neutkens
0f6cff88bc Add next-to-next-server 2018-10-05 23:40:36 +02:00
Tim Neutkens
785377d3c3
Add missing dependencies to server (#5369)
- compile default pages correctly into `.next`
- add missing runtime dependencies
2018-10-03 00:08:57 +02:00
Andy
b041fa4782 Support for wasm (#5316)
* Set a default path for wasm modules

* Added the mimetype "application/wasm" for wasm files

* Upgrade write-file-webpack-plugin to 4.4.1

* Made dynamic(import()) in test to dynamic(() => import())
2018-10-02 13:10:07 +02:00
Tim Neutkens
82d56e063a
next-server (#5357) 2018-10-02 00:55:31 +02:00
Tim Neutkens
b1c4f3aec4
Monorepo (#5341)
- Implements Lerna
- Moves all source code into `packages/next`
- Keeps integration tests in the root directory
2018-10-01 01:02:10 +02:00