Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
d0220ff3
Unverified
Commit
d0220ff3
authored
2 months ago
by
github-automation-metabase
Committed by
GitHub
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(sdk): update define function names in Next.js compat (#51071) (#51453)
Co-authored-by:
Phoomparin Mano
<
poom@metabase.com
>
parent
3bb077b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
enterprise/frontend/src/embedding-sdk/bin/.eslintrc
+6
-0
6 additions, 0 deletions
enterprise/frontend/src/embedding-sdk/bin/.eslintrc
enterprise/frontend/src/embedding-sdk/bin/generate-nextjs-compat.ts
+8
-12
8 additions, 12 deletions
.../frontend/src/embedding-sdk/bin/generate-nextjs-compat.ts
with
14 additions
and
12 deletions
enterprise/frontend/src/embedding-sdk/bin/.eslintrc
0 → 100644
+
6
−
0
View file @
d0220ff3
{
"rules": {
"no-literal-metabase-strings": "off",
"no-console": "off",
},
}
This diff is collapsed.
Click to expand it.
enterprise/frontend/src/embedding-sdk/bin/generate-nextjs-compat.ts
+
8
−
12
View file @
d0220ff3
/* eslint-disable no-console */
import
fs
from
"
fs
"
;
import
path
from
"
path
"
;
...
...
@@ -51,11 +50,10 @@ const COMPONENTS_TO_EXPORT: ComponentDefinition[] = [
// END OF CONFIGURATION
// eslint-disable-next-line no-literal-metabase-strings -- it's code
const
MetabaseProviderCode
=
`
const MetabaseProvider = ({
config,
children,
...providerProps,
}) => {
const Provider = dynamic(
() =>
...
...
@@ -70,7 +68,7 @@ const MetabaseProvider = ({
}
);
return React.createElement(Provider,
{ config }
, children);
return React.createElement(Provider,
providerProps
, children);
};
`
;
...
...
@@ -148,24 +146,23 @@ const generateAllComponents = (type: "cjs" | "js") => {
// nextjs-no-ssr.{cjs,js} => file marked as "use client" that re-exports the components wrapped in dynamic import with no ssr
// we need to re-export these helpers so they can be used without importing the entire bundle, that will make next crash because window is undefined
const
define
EmbeddingSdk
Config
=
"
c
onfig =>
c
onfig
"
;
const
define
EmbeddingSdk
Theme
=
"
theme => theme
"
;
const
define
MetabaseAuth
Config
=
"
authC
onfig =>
authC
onfig
"
;
const
define
Metabase
Theme
=
"
theme => theme
"
;
const
nextjs_cjs
=
`
module.exports.define
EmbeddingSdk
Config =
${
define
EmbeddingSdk
Config
}
;
module.exports.define
EmbeddingSdk
Theme =
${
define
EmbeddingSdk
Theme
}
;
module.exports.define
MetabaseAuth
Config =
${
define
MetabaseAuth
Config
}
;
module.exports.define
Metabase
Theme =
${
define
Metabase
Theme
}
;
module.exports = { ...module.exports, ...require("./nextjs-no-ssr.cjs") };
`
;
const
nextjs_js
=
`
export const define
EmbeddingSdk
Config =
${
define
EmbeddingSdk
Config
}
;
export const define
EmbeddingSdk
Theme =
${
define
EmbeddingSdk
Theme
}
;
export const define
MetabaseAuth
Config =
${
define
MetabaseAuth
Config
}
;
export const define
Metabase
Theme =
${
define
Metabase
Theme
}
;
export * from "./nextjs-no-ssr.js";
`
;
// eslint-disable-next-line no-literal-metabase-strings -- it's code
const
nextjs_no_ssr_cjs
=
`"use client";
const React = require("react");
...
...
@@ -179,7 +176,6 @@ module.exports.MetabaseProvider = MetabaseProvider;
${
generateAllComponents
(
"
cjs
"
)}
`
;
// eslint-disable-next-line no-literal-metabase-strings -- it's code
const
nextjs_no_ssr_js
=
`"use client";
import dynamic from "next/dynamic";
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment