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

test, fix and document all possible import types for URL imports #30165

Merged
merged 7 commits into from
Oct 24, 2021

Conversation

sokra
Copy link
Member

@sokra sokra commented Oct 22, 2021

resolve absolute URLs in CSS when using urlImports
remove [path] from static static image output path
replace file-loader with asset module, remove file-loader

Bug

  • Related issues linked using fixes #number
  • Integration tests added
  • Errors have helpful link attached, see contributing.md

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • Integration tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have helpful link attached, see contributing.md

Documentation / Examples

  • Make sure the linting passes by running yarn lint

@ijjk

This comment has been minimized.

@sokra sokra force-pushed the url-imports/css-url branch from 21feb9b to f61c574 Compare October 22, 2021 09:07
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@sokra sokra force-pushed the url-imports/css-url branch from f61c574 to 184e2c9 Compare October 22, 2021 09:53
@sokra sokra marked this pull request as draft October 22, 2021 09:53
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@sokra sokra force-pushed the url-imports/css-url branch from 184e2c9 to 0099dab Compare October 22, 2021 11:54
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@sokra sokra force-pushed the url-imports/css-url branch 2 times, most recently from 9d4df05 to 257e43f Compare October 22, 2021 13:41
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

resolve absolute URLs in CSS when using urlImports
remove `[path]` from static static image output path
replace file-loader with asset module, remove file-loader
@sokra sokra force-pushed the url-imports/css-url branch from 257e43f to f82a740 Compare October 22, 2021 18:06
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@sokra sokra marked this pull request as ready for review October 22, 2021 19:14
@ijjk

This comment has been minimized.

timneutkens
timneutkens previously approved these changes Oct 23, 2021
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

loader: require.resolve('next/dist/compiled/file-loader'),
options: {
// Hash the file for immutable cacheability
name: 'static/media/[name].[hash].[ext]',
Copy link
Member

Choose a reason for hiding this comment

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

Will the asset/resource follow the same pattern as next-image-loader is using?

'/static/media/[name].[hash:8].[ext]',

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

ijjk
ijjk previously approved these changes Oct 23, 2021
@@ -1510,6 +1510,7 @@ export default async function getBaseWebpackConfig(
sassOptions: config.sassOptions,
productionBrowserSourceMaps: config.productionBrowserSourceMaps,
future: config.future,
experimental: config.experimental,
isCraCompat: config.experimental.craCompat,
Copy link
Member

Choose a reason for hiding this comment

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

Seems like experimental.isCraCompat is no longe needed since you're passing the entire experimental object

Copy link
Member Author

Choose a reason for hiding this comment

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

done

styfle
styfle previously approved these changes Oct 23, 2021
@sokra sokra dismissed stale reviews from styfle, ijjk, and timneutkens via 50e26f3 October 24, 2021 20:02
@ijjk
Copy link
Member

ijjk commented Oct 24, 2021

Stats from current PR

Default Build (Decrease detected ✓)
General Overall decrease ✓
vercel/next.js canary vercel/next.js url-imports/css-url Change
buildDuration 21.4s 20.9s -484ms
buildDurationCached 4.2s 4.5s ⚠️ +306ms
nodeModulesSize 196 MB 196 MB -4.04 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary vercel/next.js url-imports/css-url Change
/ failed reqs 0 0
/ total time (seconds) 3.653 3.719 ⚠️ +0.07
/ avg req/sec 684.28 672.24 ⚠️ -12.04
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.931 1.975 ⚠️ +0.04
/error-in-render avg req/sec 1294.75 1265.92 ⚠️ -28.83
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary vercel/next.js url-imports/css-url Change
450.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.2 kB 42.2 kB
main-HASH.js gzip 27.7 kB 27.7 kB
webpack-HASH.js gzip 1.45 kB 1.45 kB ⚠️ +1 B
Overall change 71.5 kB 71.5 kB ⚠️ +1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js url-imports/css-url Change
polyfills-a4..dd70.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages Overall decrease ✓
vercel/next.js canary vercel/next.js url-imports/css-url Change
_app-HASH.js gzip 1.23 kB 1.23 kB
_error-HASH.js gzip 194 B 194 B
amp-HASH.js gzip 312 B 312 B
css-HASH.js gzip 327 B 327 B
dynamic-HASH.js gzip 2.38 kB 2.38 kB
head-HASH.js gzip 350 B 350 B
hooks-HASH.js gzip 635 B 635 B
image-HASH.js gzip 4.44 kB 4.44 kB
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 1.87 kB 1.87 kB
routerDirect..HASH.js gzip 321 B 321 B
script-HASH.js gzip 383 B 383 B
withRouter-HASH.js gzip 318 B 318 B
9a34b27eb3f9..27d.css gzip 125 B N/A N/A
334f979574ae..6f4.css gzip N/A 106 B N/A
Overall change 13.2 kB 13.1 kB -19 B
Client Build Manifests
vercel/next.js canary vercel/next.js url-imports/css-url Change
_buildManifest.js gzip 459 B 459 B
Overall change 459 B 459 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary vercel/next.js url-imports/css-url Change
index.html gzip 535 B 534 B -1 B
link.html gzip 547 B 546 B -1 B
withRouter.html gzip 528 B 527 B -1 B
Overall change 1.61 kB 1.61 kB -3 B

Diffs

Diff for _buildManifest.js
@@ -4,7 +4,7 @@ self.__BUILD_MANIFEST = {
   "/_error": ["static\u002Fchunks\u002Fpages\u002F_error-97db2c91e74bb63f.js"],
   "/amp": ["static\u002Fchunks\u002Fpages\u002Famp-8c7b17a56b7abb6e.js"],
   "/css": [
-    "static\u002Fcss\u002Fb05d9375ec06fe1b.css",
+    "static\u002Fcss\u002F7edf9ee7c3885268.css",
     "static\u002Fchunks\u002Fpages\u002Fcss-99ad492aad2c14e4.js"
   ],
   "/dynamic": [
Diff for webpack-HASH.js
@@ -171,7 +171,7 @@
     /******/ // This function allow to reference all chunks
     /******/ __webpack_require__.miniCssF = function(chunkId) {
       /******/ // return url for filenames based on template
-      /******/ return "static/css/" + "b05d9375ec06fe1b" + ".css";
+      /******/ return "static/css/" + "7edf9ee7c3885268" + ".css";
       /******/
     };
     /******/
Diff for 7edf9ee7c3885268.css
@@ -0,0 +1,4 @@
+.css_helloWorld__2Fhmt {
+  color: green;
+  background: url(/_next/static/media/nextjs.cae0b805.png);
+}
Diff for b05d9375ec06fe1b.css
deleted
Diff for index.html
@@ -11,7 +11,7 @@
       src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-020dd12211ca2daa.js"
+      src="/_next/static/chunks/webpack-43980cc4f59eb55b.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -11,7 +11,7 @@
       src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-020dd12211ca2daa.js"
+      src="/_next/static/chunks/webpack-43980cc4f59eb55b.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -11,7 +11,7 @@
       src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-020dd12211ca2daa.js"
+      src="/_next/static/chunks/webpack-43980cc4f59eb55b.js"
       defer=""
     ></script>
     <script

Default Build with SWC (Increase detected ⚠️)
General Overall decrease ✓
vercel/next.js canary vercel/next.js url-imports/css-url Change
buildDuration 18.4s 17.9s -437ms
buildDurationCached 4.2s 4.3s ⚠️ +39ms
nodeModulesSize 196 MB 196 MB -4.04 kB
Page Load Tests Overall increase ✓
vercel/next.js canary vercel/next.js url-imports/css-url Change
/ failed reqs 0 0
/ total time (seconds) 3.775 3.796 ⚠️ +0.02
/ avg req/sec 662.19 658.62 ⚠️ -3.57
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.979 1.898 -0.08
/error-in-render avg req/sec 1263.19 1317.25 +54.06
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary vercel/next.js url-imports/css-url Change
450.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.2 kB 42.2 kB
main-HASH.js gzip 27.8 kB 27.8 kB
webpack-HASH.js gzip 1.43 kB 1.43 kB ⚠️ +1 B
Overall change 71.6 kB 71.6 kB ⚠️ +1 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js url-imports/css-url Change
polyfills-a4..dd70.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages Overall decrease ✓
vercel/next.js canary vercel/next.js url-imports/css-url Change
_app-HASH.js gzip 1.22 kB 1.22 kB
_error-HASH.js gzip 180 B 180 B
amp-HASH.js gzip 305 B 305 B
css-HASH.js gzip 321 B 321 B
dynamic-HASH.js gzip 2.38 kB 2.38 kB
head-HASH.js gzip 342 B 342 B
hooks-HASH.js gzip 621 B 621 B
image-HASH.js gzip 4.46 kB 4.46 kB
index-HASH.js gzip 256 B 256 B
link-HASH.js gzip 1.9 kB 1.9 kB
routerDirect..HASH.js gzip 314 B 314 B
script-HASH.js gzip 375 B 375 B
withRouter-HASH.js gzip 309 B 309 B
9a34b27eb3f9..27d.css gzip 125 B N/A N/A
334f979574ae..6f4.css gzip N/A 106 B N/A
Overall change 13.1 kB 13.1 kB -19 B
Client Build Manifests
vercel/next.js canary vercel/next.js url-imports/css-url Change
_buildManifest.js gzip 459 B 459 B
Overall change 459 B 459 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary vercel/next.js url-imports/css-url Change
index.html gzip 533 B 533 B
link.html gzip 546 B 547 B ⚠️ +1 B
withRouter.html gzip 527 B 527 B
Overall change 1.61 kB 1.61 kB ⚠️ +1 B

Diffs

Diff for _buildManifest.js
@@ -4,7 +4,7 @@ self.__BUILD_MANIFEST = {
   "/_error": ["static\u002Fchunks\u002Fpages\u002F_error-97db2c91e74bb63f.js"],
   "/amp": ["static\u002Fchunks\u002Fpages\u002Famp-8c7b17a56b7abb6e.js"],
   "/css": [
-    "static\u002Fcss\u002Fb05d9375ec06fe1b.css",
+    "static\u002Fcss\u002F7edf9ee7c3885268.css",
     "static\u002Fchunks\u002Fpages\u002Fcss-99ad492aad2c14e4.js"
   ],
   "/dynamic": [
Diff for webpack-HASH.js
@@ -171,7 +171,7 @@
     /******/ // This function allow to reference all chunks
     /******/ __webpack_require__.miniCssF = function(chunkId) {
       /******/ // return url for filenames based on template
-      /******/ return "static/css/" + "b05d9375ec06fe1b" + ".css";
+      /******/ return "static/css/" + "7edf9ee7c3885268" + ".css";
       /******/
     };
     /******/
Diff for 7edf9ee7c3885268.css
@@ -0,0 +1,4 @@
+.css_helloWorld__2Fhmt {
+  color: green;
+  background: url(/_next/static/media/nextjs.cae0b805.png);
+}
Diff for b05d9375ec06fe1b.css
deleted
Diff for index.html
@@ -11,7 +11,7 @@
       src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-020dd12211ca2daa.js"
+      src="/_next/static/chunks/webpack-43980cc4f59eb55b.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -11,7 +11,7 @@
       src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-020dd12211ca2daa.js"
+      src="/_next/static/chunks/webpack-43980cc4f59eb55b.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -11,7 +11,7 @@
       src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-020dd12211ca2daa.js"
+      src="/_next/static/chunks/webpack-43980cc4f59eb55b.js"
       defer=""
     ></script>
     <script
Commit: 50e26f3

@ijjk
Copy link
Member

ijjk commented Oct 24, 2021

Failing test suites

Commit: 50e26f3

test/development/basic/hmr.test.ts

  • basic HMR > Error Recovery > should recover from errors in the render function
  • basic HMR > Error Recovery > should recover after a bad return from the render function
Expand output

● basic HMR › Error Recovery › should recover from errors in the render function

TIMED OUT: /This is the about page/

  437 |
  438 |   if (hardError) {
> 439 |     throw new Error('TIMED OUT: ' + regex + '\n\n' + content)
      |           ^
  440 |   }
  441 |   return false
  442 | }

  at Object.check (lib/next-test-utils.js:439:11)
  at Object.<anonymous> (development/basic/hmr.test.ts:469:9)

● basic HMR › Error Recovery › should recover after a bad return from the render function

TIMED OUT: /This is the about page/

  437 |
  438 |   if (hardError) {
> 439 |     throw new Error('TIMED OUT: ' + regex + '\n\n' + content)
      |           ^
  440 |   }
  441 |   return false
  442 | }

  at Object.check (lib/next-test-utils.js:439:11)
  at Object.<anonymous> (development/basic/hmr.test.ts:572:9)

@sokra sokra merged commit 04e1e01 into canary Oct 24, 2021
@sokra sokra deleted the url-imports/css-url branch October 24, 2021 23:54
@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants