Skip to content

Commit

Permalink
fix: make sure to support the latest @loadable/babel plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Dec 18, 2023
1 parent bd8bd74 commit f5582ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@loadable/babel-plugin": "^5.15.3",
"@loadable/babel-plugin": "^5.16.1",
"@loadable/component": "^5.16.2",
"@loadable/server": "^5.16.2",
"@loadable/webpack-plugin": "^5.15.2",
Expand Down
13 changes: 4 additions & 9 deletions src/next-dynamic-loadable-shim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,13 @@ export default function (
// so the following is a bit hacky but allows us to preload all promises before rendering
// and then return the right component in `resolveComponent`.
const possiblePromise =
typeof dynamicImport === 'function'
? // @ts-ignore
dynamicImport()
: 'requireSync' in dynamicImport
? // @ts-ignore
dynamicImport.requireSync()
: undefined
if (typeof possiblePromise === 'undefined') {
// @ts-ignore
'requireSync' in dynamicImport && dynamicImport.requireSync()
if (!possiblePromise) {
throw new Error(
`[next-static] Unable to convert dynamic import of ${String(
possiblePromise
)}.`
)}. Please make sure you have the latest version (>= 5.16.1 of \`@loadable/babel-plugin\`) installed`
)
}
if (possiblePromise.then) {
Expand Down
2 changes: 1 addition & 1 deletion src_cjs/babel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default (api: any, options?: any): any => {
plugins: [
[
require('@loadable/babel-plugin'),
{ defaultImportSpecifier: 'dynamic' },
{ signatures: [{name: 'default', from: 'next/dynamic'}] },
],
...(result.plugins?.filter((plugin) => {
return plugin.default !== loadablePlugin
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ __metadata:
resolution: "@freshcells/next-static-components@workspace:."
dependencies:
"@babel/core": ^7.20.12
"@loadable/babel-plugin": ^5.15.3
"@loadable/babel-plugin": ^5.16.1
"@loadable/component": ^5.16.2
"@loadable/server": ^5.16.2
"@loadable/webpack-plugin": ^5.15.2
Expand Down Expand Up @@ -849,14 +849,14 @@ __metadata:
languageName: node
linkType: hard

"@loadable/babel-plugin@npm:^5.15.3":
version: 5.15.3
resolution: "@loadable/babel-plugin@npm:5.15.3"
"@loadable/babel-plugin@npm:^5.16.1":
version: 5.16.1
resolution: "@loadable/babel-plugin@npm:5.16.1"
dependencies:
"@babel/plugin-syntax-dynamic-import": "npm:^7.7.4"
"@babel/plugin-syntax-dynamic-import": ^7.7.4
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: bea73fb9019e2b5d7418b52cfb63abd6838291ccc2ad64f65c7c17ff7eb1dae5dc4b471cf9a1df39a89cc8ab6fdfac47cae66f1d9827cb91478416708b96bbb9
checksum: f7a1eed76ca6749d66f44d5d690c5812870cda7005fb02ac31135ad99d444d73919c3d31cbbcd94c7c9444641161406b4c42e44a9fee479f533ffafc62f8ad58
languageName: node
linkType: hard

Expand Down

0 comments on commit f5582ef

Please sign in to comment.