-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(loadable-components)!: support lazy and configuring
- Loading branch information
Showing
49 changed files
with
415 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
1 change: 1 addition & 0 deletions
1
...able-components/tests/fixture/aggressive import/should work with destructuration/input.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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import loadable from "@loadable/component"; | ||
loadable(({ foo }) => import(/* webpackChunkName: "Pages" */ `./${foo}`)); |
1 change: 1 addition & 0 deletions
1
...ble-components/tests/fixture/aggressive import/should work with destructuration/output.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import loadable from "@loadable/component"; | ||
loadable({ | ||
resolved: {}, | ||
chunkName ({ foo }) { | ||
|
1 change: 1 addition & 0 deletions
1
...-components/tests/fixture/aggressive import/with webpackChunkName/should keep it/input.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
1 change: 1 addition & 0 deletions
1
...components/tests/fixture/aggressive import/with webpackChunkName/should keep it/output.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import loadable from "@loadable/component"; | ||
loadable({ | ||
resolved: {}, | ||
chunkName (props) { | ||
|
1 change: 1 addition & 0 deletions
1
...mponents/tests/fixture/aggressive import/with webpackChunkName/should replace it/input.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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import loadable from "@loadable/component"; | ||
loadable((props) => import(/* webpackChunkName: "Pages" */ `./${props.foo}`)); |
1 change: 1 addition & 0 deletions
1
...ponents/tests/fixture/aggressive import/with webpackChunkName/should replace it/output.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import loadable from "@loadable/component"; | ||
loadable({ | ||
resolved: {}, | ||
chunkName (props) { | ||
|
1 change: 1 addition & 0 deletions
1
...ixture/aggressive import/without webpackChunkName/should support complex request/input.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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import loadable from "@loadable/component"; | ||
loadable((props) => import(`./dir/${props.foo}/test`)); |
1 change: 1 addition & 0 deletions
1
...xture/aggressive import/without webpackChunkName/should support complex request/output.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import loadable from "@loadable/component"; | ||
loadable({ | ||
resolved: {}, | ||
chunkName (props) { | ||
|
1 change: 1 addition & 0 deletions
1
.../fixture/aggressive import/without webpackChunkName/should support destructuring/input.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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import loadable from "@loadable/component"; | ||
loadable(({ foo }) => import(`./dir/${foo}/test`)); |
1 change: 1 addition & 0 deletions
1
...fixture/aggressive import/without webpackChunkName/should support destructuring/output.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import loadable from "@loadable/component"; | ||
loadable({ | ||
resolved: {}, | ||
chunkName ({ foo }) { | ||
|
1 change: 1 addition & 0 deletions
1
...fixture/aggressive import/without webpackChunkName/should support simple request/input.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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import loadable from "@loadable/component"; | ||
loadable((props) => import(`./${props.foo}`)); |
1 change: 1 addition & 0 deletions
1
...ixture/aggressive import/without webpackChunkName/should support simple request/output.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import loadable from "@loadable/component"; | ||
loadable({ | ||
resolved: {}, | ||
chunkName (props) { | ||
|
3 changes: 3 additions & 0 deletions
3
packages/loadable-components/tests/fixture/lazy/should be transpiled too/input.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,3 @@ | ||
import { lazy } from "@loadable/component"; | ||
|
||
lazy(() => import("./ModA")); |
40 changes: 40 additions & 0 deletions
40
packages/loadable-components/tests/fixture/lazy/should be transpiled too/output.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 @@ | ||
import { lazy } from "@loadable/component"; | ||
|
||
lazy({ | ||
resolved: {}, | ||
chunkName () { | ||
return "ModA"; | ||
}, | ||
isReady (props) { | ||
const key = this.resolve(props); | ||
if (this.resolved[key] !== true) { | ||
return false; | ||
} | ||
if (typeof __webpack_modules__ !== 'undefined') { | ||
return !!__webpack_modules__[key]; | ||
} | ||
return false; | ||
}, | ||
importAsync: ()=>import(/*webpackChunkName: "ModA"*/ "./ModA"), | ||
requireAsync (props) { | ||
const key = this.resolve(props); | ||
this.resolved[key] = false; | ||
return this.importAsync(props).then((resolved)=>{ | ||
this.resolved[key] = true; | ||
return resolved; | ||
}); | ||
}, | ||
requireSync (props) { | ||
const id = this.resolve(props); | ||
if (typeof __webpack_require__ !== 'undefined') { | ||
return __webpack_require__(id); | ||
} | ||
return eval('module.require')(id); | ||
}, | ||
resolve () { | ||
if (require.resolveWeak) { | ||
return require.resolveWeak("./ModA"); | ||
} | ||
return eval('require.resolve')("./ModA"); | ||
} | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/loadable-components/tests/fixture/lazy/should not work without imported/input.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,3 @@ | ||
import { lazy } from "react"; | ||
|
||
lazy(() => import("./ModA")); |
3 changes: 3 additions & 0 deletions
3
packages/loadable-components/tests/fixture/lazy/should not work without imported/output.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,3 @@ | ||
import { lazy } from "react"; | ||
|
||
lazy(() => import("./ModA")); |
3 changes: 3 additions & 0 deletions
3
packages/loadable-components/tests/fixture/lazy/should work with renamed specifier/input.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,3 @@ | ||
import { lazy as renamedLazy } from "@loadable/component"; | ||
|
||
renamedLazy(() => import("./ModA")); |
Oops, something went wrong.