-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes to allow lazy compilation for import() (#32441)
- Loading branch information
Showing
42 changed files
with
687 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/next-swc/crates/core/tests/fixture/next-dynamic/duplicated-imports/output-dev.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import dynamic1 from 'next/dynamic' | ||
import dynamic2 from 'next/dynamic' | ||
const DynamicComponent1 = dynamic1(() => import('../components/hello1'), { | ||
loadableGenerated: { | ||
modules: ['some-file.js -> ' + '../components/hello1'], | ||
}, | ||
}) | ||
const DynamicComponent2 = dynamic2(() => import('../components/hello2'), { | ||
loadableGenerated: { | ||
modules: ['some-file.js -> ' + '../components/hello2'], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/next-swc/crates/core/tests/fixture/next-dynamic/member-with-same-name/output-dev.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import dynamic from 'next/dynamic' | ||
import somethingElse from 'something-else' | ||
const DynamicComponent = dynamic(() => import('../components/hello'), { | ||
loadableGenerated: { | ||
modules: ['some-file.js -> ' + '../components/hello'], | ||
}, | ||
}) | ||
somethingElse.dynamic('should not be transformed') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/next-swc/crates/core/tests/fixture/next-dynamic/no-options/output-dev.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import dynamic from 'next/dynamic' | ||
const DynamicComponent = dynamic(() => import('../components/hello'), { | ||
loadableGenerated: { | ||
modules: ['some-file.js -> ' + '../components/hello'], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/next-swc/crates/core/tests/fixture/next-dynamic/with-options/output-dev.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import dynamic from "next/dynamic"; | ||
const DynamicComponentWithCustomLoading = dynamic(()=>import("../components/hello") | ||
, { | ||
loadableGenerated: { | ||
modules: [ | ||
"some-file.js -> " + "../components/hello" | ||
] | ||
}, | ||
loading: ()=><p >...</p> | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/next-swc/crates/core/tests/fixture/next-dynamic/wrapped-import/output-dev.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import dynamic from "next/dynamic"; | ||
const DynamicComponent = dynamic(()=>handleImport(import("./components/hello")) | ||
, { | ||
loadableGenerated: { | ||
modules: [ | ||
"some-file.js -> " + "./components/hello" | ||
] | ||
}, | ||
loading: ()=>null | ||
, | ||
ssr: false | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/next/bundles/webpack/packages/lazy-compilation-node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* global __resourceQuery */ | ||
|
||
"use strict"; | ||
|
||
var urlBase = decodeURIComponent(__resourceQuery.slice(1)); | ||
exports.keepAlive = function (options) { | ||
var data = options.data; | ||
var onError = options.onError; | ||
var active = options.active; | ||
var module = options.module; | ||
var response; | ||
var request = ( | ||
urlBase.startsWith("https") ? require("https") : require("http") | ||
).request( | ||
urlBase + data, | ||
{ | ||
agent: false, | ||
headers: { accept: "text/event-stream" } | ||
}, | ||
function (res) { | ||
response = res; | ||
response.on("error", errorHandler); | ||
if (!active && !module.hot) { | ||
console.log( | ||
"Hot Module Replacement is not enabled. Waiting for process restart..." | ||
); | ||
} | ||
} | ||
); | ||
function errorHandler(err) { | ||
err.message = | ||
"Problem communicating active modules to the server: " + err.message; | ||
onError(err); | ||
} | ||
request.on("error", errorHandler); | ||
request.end(); | ||
return function () { | ||
response.destroy(); | ||
}; | ||
}; |
Oops, something went wrong.