-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Deepnote style data frames #28
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
Changes from all commits
a12d042
c19acd4
066229a
e36b9c0
558035f
5113db6
1ba9ab4
a51a150
98d7fe6
3a4d579
4fa78e2
8ae05ab
3597ce3
9fec8d4
0537364
9b9216a
e5a1bba
e7cccb9
895fe09
54ca963
8309267
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,9 @@ import { lessLoader } from 'esbuild-plugin-less'; | |||||||||||||||||||||||||||
| import fs from 'fs-extra'; | ||||||||||||||||||||||||||||
| import { getZeroMQPreBuildsFoldersToKeep, getBundleConfiguration, bundleConfiguration } from '../webpack/common'; | ||||||||||||||||||||||||||||
| import ImportGlobPlugin from 'esbuild-plugin-import-glob'; | ||||||||||||||||||||||||||||
| import postcss from 'postcss'; | ||||||||||||||||||||||||||||
| import tailwindcss from '@tailwindcss/postcss'; | ||||||||||||||||||||||||||||
| import autoprefixer from 'autoprefixer'; | ||||||||||||||||||||||||||||
| const plugin = require('node-stdlib-browser/helpers/esbuild/plugin'); | ||||||||||||||||||||||||||||
| const stdLibBrowser = require('node-stdlib-browser'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -86,7 +89,11 @@ const loader: { [ext: string]: Loader } = { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // https://github.com/evanw/esbuild/issues/20#issuecomment-802269745 | ||||||||||||||||||||||||||||
| // https://github.com/hyrious/esbuild-plugin-style | ||||||||||||||||||||||||||||
| function style({ minify = true, charset = 'utf8' }: StylePluginOptions = {}): Plugin { | ||||||||||||||||||||||||||||
| function style({ | ||||||||||||||||||||||||||||
| minify = true, | ||||||||||||||||||||||||||||
| charset = 'utf8', | ||||||||||||||||||||||||||||
| enableTailwind = false | ||||||||||||||||||||||||||||
| }: StylePluginOptions & { enableTailwind?: boolean } = {}): Plugin { | ||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||
| name: 'style', | ||||||||||||||||||||||||||||
| setup({ onResolve, onLoad }) { | ||||||||||||||||||||||||||||
|
|
@@ -132,6 +139,32 @@ function style({ minify = true, charset = 'utf8' }: StylePluginOptions = {}): Pl | |||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| onLoad({ filter: /.*/, namespace: 'style-content' }, async (args) => { | ||||||||||||||||||||||||||||
| // Process with PostCSS/Tailwind if enabled and file exists | ||||||||||||||||||||||||||||
| if (enableTailwind && args.path.includes('tailwind.css') && fs.existsSync(args.path)) { | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded filename check is fragile. The check Consider a more flexible approach (e.g., check for |
||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| const cssContent = await fs.readFile(args.path, 'utf8'); | ||||||||||||||||||||||||||||
| const result = await postcss([tailwindcss, autoprefixer]).process(cssContent, { | ||||||||||||||||||||||||||||
| from: args.path, | ||||||||||||||||||||||||||||
| to: args.path | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const options = { ...opt, stdin: { contents: result.css, loader: 'css' } }; | ||||||||||||||||||||||||||||
| options.loader = options.loader || {}; | ||||||||||||||||||||||||||||
| // Add the same loaders we add for other places | ||||||||||||||||||||||||||||
| Object.keys(loader).forEach((key) => { | ||||||||||||||||||||||||||||
| if (options.loader && !options.loader[key]) { | ||||||||||||||||||||||||||||
| options.loader[key] = loader[key]; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| const { errors, warnings, outputFiles } = await esbuild.build(options); | ||||||||||||||||||||||||||||
| return { errors, warnings, contents: outputFiles![0].text, loader: 'text' }; | ||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||
| console.error(`PostCSS processing failed for ${args.path}:`, error); | ||||||||||||||||||||||||||||
| throw error; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Default behavior for other CSS files | ||||||||||||||||||||||||||||
| const options = { entryPoints: [args.path], ...opt }; | ||||||||||||||||||||||||||||
| options.loader = options.loader || {}; | ||||||||||||||||||||||||||||
| // Add the same loaders we add for other places | ||||||||||||||||||||||||||||
|
|
@@ -140,7 +173,9 @@ function style({ minify = true, charset = 'utf8' }: StylePluginOptions = {}): Pl | |||||||||||||||||||||||||||
| options.loader[key] = loader[key]; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const { errors, warnings, outputFiles } = await esbuild.build(options); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return { errors, warnings, contents: outputFiles![0].text, loader: 'text' }; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
@@ -158,7 +193,9 @@ function createConfig( | |||||||||||||||||||||||||||
| const plugins: Plugin[] = []; | ||||||||||||||||||||||||||||
| let define: SameShape<BuildOptions, BuildOptions>['define'] = undefined; | ||||||||||||||||||||||||||||
| if (target === 'web') { | ||||||||||||||||||||||||||||
| plugins.push(style()); | ||||||||||||||||||||||||||||
| // Enable Tailwind processing for dataframe renderer | ||||||||||||||||||||||||||||
| const enableTailwind = source.includes(path.join('dataframe-renderer', 'index.ts')); | ||||||||||||||||||||||||||||
| plugins.push(style({ enableTailwind })); | ||||||||||||||||||||||||||||
|
Comment on lines
+196
to
+198
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider more robust path matching. The check Example: - const enableTailwind = source.includes(path.join('dataframe-renderer', 'index.ts'));
+ const enableTailwind = source === path.join(extensionFolder, 'src', 'webviews', 'webview-side', 'dataframe-renderer', 'index.ts');📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| plugins.push(lessLoader()); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| define = { | ||||||||||||||||||||||||||||
|
|
@@ -287,6 +324,11 @@ async function buildAll() { | |||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||
| { target: 'web', watch: watchAll } | ||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||
| build( | ||||||||||||||||||||||||||||
| path.join(extensionFolder, 'src', 'webviews', 'webview-side', 'dataframe-renderer', 'index.ts'), | ||||||||||||||||||||||||||||
| path.join(extensionFolder, 'dist', 'webviews', 'webview-side', 'dataframeRenderer', 'dataframeRenderer.js'), | ||||||||||||||||||||||||||||
| { target: 'web', watch: isWatchMode } | ||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
| build( | ||||||||||||||||||||||||||||
| path.join(extensionFolder, 'src', 'webviews', 'webview-side', 'variable-view', 'index.tsx'), | ||||||||||||||||||||||||||||
| path.join(extensionFolder, 'dist', 'webviews', 'webview-side', 'viewers', 'variableView.js'), | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, we were not allowed to install the
@deepnote/blockspackage.