-
Notifications
You must be signed in to change notification settings - Fork 4
Migrate to ESM & update the Vega libraries #214
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
Open
Artmann
wants to merge
18
commits into
main
Choose a base branch
from
chris/migrate-to-esm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
64b084f
chore(deps): bump vega-expression and vega-lite
dependabot[bot] 8ed354d
chore(deps): update dependency @deepnote/blocks to v1.3.6 (#182)
renovate[bot] b937920
update vega versions.
Artmann f7f67a5
chore: Migrate to ESM
Artmann 175218f
Merge branch 'main' into chris/migrate-to-esm
Artmann f3a8438
fix postInstall
Artmann 5d6b6b5
make eslint-rules commonjs
Artmann cdd94d9
fix audit and spellcheck
Artmann 74d9fc8
update js-yaml
Artmann 5925dd8
Don't commit tsconfig.tsbuildinfo
Artmann 00c0b48
pr feedback
Artmann 9c4d971
remove codecov
Artmann bdf0c6b
fix(ci): add --no-dependencies flag to vsce package command
Artmann 5908dd0
pr feedback
Artmann e474b7e
add vegalite types.
Artmann f80b94a
feedback
Artmann 8b31e74
address all the feedback.
Artmann 1d63873
support both v5 and v6 charts.
Artmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -73,3 +73,4 @@ tmp | |
| vscode.d.ts | ||
| vscode.proposed.*.d.ts | ||
| xunit-test-results.xml | ||
| tsconfig.tsbuildinfo | ||
File renamed without changes.
This file contains hidden or 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 hidden or 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,9 +1,10 @@ | ||
| { | ||
| "spec": "./out/**/*.unit.test.js", | ||
| "require": ["source-map-support/register", "out/test/unittests.js"], | ||
| "reporter": "mocha-multi-reporters", | ||
| "reporter-option": "configFile=build/.mocha-multi-reporters.config", | ||
| "loader": ["./build/mocha-esm-loader.js"], | ||
| "require": ["./out/test/unittests.js"], | ||
| "reporter": "spec", | ||
| "ui": "tdd", | ||
| "recursive": true, | ||
| "colors": true | ||
| "colors": true, | ||
| "node-option": ["no-warnings=ExperimentalWarning", "loader=./build/mocha-esm-loader.js"] | ||
| } |
This file contains hidden or 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,9 +1,10 @@ | ||
| { | ||
| "spec": "./out/**/*.unit.test.js", | ||
| "require": ["out/test/unittests.js"], | ||
| "loader": ["./build/mocha-esm-loader.js"], | ||
| "reporter": "mocha-multi-reporters", | ||
| "reporter-option": "configFile=build/.mocha-multi-reporters.config", | ||
| "ui": "tdd", | ||
| "recursive": true, | ||
| "colors": true | ||
| "colors": true, | ||
| "node-option": ["--no-warnings=ExperimentalWarning"] | ||
| } |
This file contains hidden or 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,8 +1,9 @@ | ||
| { | ||
| "require": ["ts-node/register", "out/test/unittests.js"], | ||
| "loader": ["ts-node/esm", "./build/mocha-esm-loader.js"], | ||
| "reporter": "mocha-multi-reporters", | ||
| "reporter-option": "configFile=build/.mocha-multi-reporters.config", | ||
| "ui": "tdd", | ||
| "recursive": true, | ||
| "colors": true | ||
| "colors": true, | ||
| "node-option": ["--no-warnings=ExperimentalWarning"] | ||
| } |
This file contains hidden or 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,98 @@ | ||
| #!/usr/bin/env node | ||
| // Script to add .js extensions to all relative imports in TypeScript files | ||
| // This is required for ESM compatibility | ||
|
|
||
| import { promises as fs } from 'fs'; | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { dirname } from 'path'; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = dirname(__filename); | ||
|
|
||
| const rootDir = path.join(__dirname, '..'); | ||
| const srcDir = path.join(rootDir, 'src'); | ||
|
|
||
| // Regex patterns to match import statements with relative paths | ||
| // Updated to handle multi-line imports/exports by using [\s\S] to match newlines | ||
| const importPatterns = [ | ||
| // import ... from './path' or '../path' (supports multi-line named imports) | ||
| /^(\s*import\s+[\s\S]+?from\s+['"])(\.\/.+?|\.\.?\/.+?)(['"])/gm, | ||
| // export ... from './path' or '../path' (supports multi-line named exports) | ||
| /^(\s*export\s+[\s\S]+?from\s+['"])(\.\/.+?|\.\.?\/.+?)(['"])/gm, | ||
| // import('./path') or import('../path') (supports newlines before parentheses and quotes) | ||
| /(\bimport[\s\S]*?\([\s\S]*?['"])(\.\/.+?|\.\.?\/.+?)(['"])/gm, | ||
| // await import('./path') (supports newlines in await import statements) | ||
| /(\bawait\s+import[\s\S]*?\([\s\S]*?['"])(\.\/.+?|\.\.?\/.+?)(['"])/gm, | ||
| ]; | ||
|
|
||
| async function getAllTsFiles(dir) { | ||
| const files = []; | ||
| const entries = await fs.readdir(dir, { withFileTypes: true }); | ||
|
|
||
| for (const entry of entries) { | ||
| const fullPath = path.join(dir, entry.name); | ||
|
|
||
| if (entry.isDirectory()) { | ||
| // Skip node_modules, out, dist, etc. | ||
| if (!['node_modules', 'out', 'dist', '.git', '.vscode', 'resources'].includes(entry.name)) { | ||
| files.push(...(await getAllTsFiles(fullPath))); | ||
| } | ||
| } else if ((entry.name.endsWith('.ts') || entry.name.endsWith('.tsx')) && !entry.name.endsWith('.d.ts')) { | ||
| // Include .ts and .tsx files, but exclude .d.ts declaration files | ||
| files.push(fullPath); | ||
| } | ||
| } | ||
|
|
||
| return files; | ||
| } | ||
|
|
||
| function addJsExtension(content) { | ||
| let modified = content; | ||
| let changeCount = 0; | ||
|
|
||
| for (const pattern of importPatterns) { | ||
| modified = modified.replace(pattern, (match, before, importPath, after) => { | ||
| // Skip if already has an extension | ||
| if (/\.(js|ts|tsx|json|css|less|svg|png|jpg)$/i.test(importPath)) { | ||
| return match; | ||
| } | ||
|
|
||
| changeCount++; | ||
| return `${before}${importPath}.js${after}`; | ||
| }); | ||
| } | ||
|
|
||
| return { content: modified, changed: changeCount > 0, changeCount }; | ||
| } | ||
|
|
||
| async function main() { | ||
| console.log('🔍 Finding all TypeScript files in src/...'); | ||
| const tsFiles = await getAllTsFiles(srcDir); | ||
| console.log(`📁 Found ${tsFiles.length} TypeScript files\n`); | ||
|
|
||
| let totalFilesChanged = 0; | ||
| let totalImportsChanged = 0; | ||
|
|
||
| for (const file of tsFiles) { | ||
| const content = await fs.readFile(file, 'utf-8'); | ||
| const { content: newContent, changed, changeCount } = addJsExtension(content); | ||
|
|
||
| if (changed) { | ||
| await fs.writeFile(file, newContent, 'utf-8'); | ||
| totalFilesChanged++; | ||
| totalImportsChanged += changeCount; | ||
| const relativePath = path.relative(rootDir, file); | ||
| console.log(`✅ ${relativePath} (${changeCount} import${changeCount > 1 ? 's' : ''})`); | ||
| } | ||
| } | ||
|
|
||
| console.log(`\n✨ Done!`); | ||
| console.log(`📊 Modified ${totalFilesChanged} files`); | ||
| console.log(`🔗 Updated ${totalImportsChanged} import statements`); | ||
| } | ||
|
|
||
| main().catch(error => { | ||
| console.error('❌ Error:', error); | ||
| process.exit(1); | ||
| }); | ||
This file contains hidden or 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 hidden or 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 hidden or 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,8 +1,8 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| 'use strict'; | ||
|
|
||
| const util = require('./util'); | ||
| exports.ExtensionRootDir = util.ExtensionRootDir; | ||
| exports.isWindows = /^win/.test(process.platform); | ||
| exports.isCI = process.env.TF_BUILD !== undefined || process.env.GITHUB_ACTIONS === 'true'; | ||
| import { ExtensionRootDir as _ExtensionRootDir } from './util.js'; | ||
|
|
||
| export const ExtensionRootDir = _ExtensionRootDir; | ||
| export const isWindows = /^win/.test(process.platform); | ||
| export const isCI = process.env.TF_BUILD !== undefined || process.env.GITHUB_ACTIONS === 'true'; | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.