Skip to content

Commit

Permalink
refactor: stop using experimental syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Nov 6, 2024
1 parent 4ef6e0d commit b66efc8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
6 changes: 4 additions & 2 deletions demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { defineConfig } from 'vite'
import importMetaUrlPlugin from '@codingame/esbuild-import-meta-url-plugin'
import * as fs from 'fs'
import path from 'path'
import pkg from './package.json' assert { type: 'json' }
const pkg = JSON.parse(
fs.readFileSync(new URL('./package.json', import.meta.url).pathname).toString()
)

const localDependencies = Object.entries(pkg.dependencies)
const localDependencies = Object.entries(pkg.dependencies as Record<string, string>)
.filter(([, version]) => version.startsWith('file:../'))
.map(([name]) => name)
export default defineConfig({
Expand Down
7 changes: 5 additions & 2 deletions demo/vite.netlify.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { defineConfig } from 'vite'
import pkg from './package.json' assert { type: 'json' }
import * as fs from 'fs'
const pkg = JSON.parse(
fs.readFileSync(new URL('./package.json', import.meta.url).pathname).toString()
)

const localDependencies = Object.entries(pkg.dependencies)
const localDependencies = Object.entries(pkg.dependencies as Record<string, string>)
.filter(([, version]) => version.startsWith('file:../'))
.map(([name]) => name)

Expand Down
5 changes: 4 additions & 1 deletion rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import * as fs from 'node:fs'
import * as nodePath from 'node:path'
import { fileURLToPath } from 'node:url'
import metadataPlugin from './rollup-metadata-plugin'
import pkg from '../package.json' assert { type: 'json' }

const pkg = JSON.parse(
fs.readFileSync(new URL('../package.json', import.meta.url).pathname).toString()
)

const __dirname = nodePath.dirname(fileURLToPath(import.meta.url))

Expand Down
4 changes: 3 additions & 1 deletion rollup/rollup.default-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import * as path from 'path'
import { fileURLToPath } from 'url'
import metadataPlugin from './rollup-metadata-plugin'
import extensionDirectoryPlugin from '../dist/rollup-extension-directory-plugin/rollup-extension-directory-plugin.js'
import pkg from '../package.json' assert { type: 'json' }
const pkg = JSON.parse(
fs.readFileSync(new URL('../package.json', import.meta.url).pathname).toString()
)

const __dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down
4 changes: 3 additions & 1 deletion rollup/rollup.language-packs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import * as fs from 'fs'
import * as path from 'path'
import { fileURLToPath } from 'url'
import * as fsPromise from 'fs/promises'
import pkg from '../package.json' assert { type: 'json' }
const pkg = JSON.parse(
fs.readFileSync(new URL('../package.json', import.meta.url).pathname).toString()
)

const __dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down
5 changes: 4 additions & 1 deletion rollup/rollup.monaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { PackageJson } from 'type-fest'
import replace from '@rollup/plugin-replace'
import glob from 'fast-glob'
import * as path from 'path'
import * as fs from 'fs'
import { fileURLToPath } from 'url'
import pkg from '../package.json' assert { type: 'json' }
const pkg = JSON.parse(
fs.readFileSync(new URL('../package.json', import.meta.url).pathname).toString()
)

const __dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down
9 changes: 7 additions & 2 deletions rollup/rollup.rollup-plugins.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import json from '@rollup/plugin-json'
import { PackageJson } from 'type-fest'
import * as path from 'path'
import { fileURLToPath } from 'url'
import * as fs from 'fs'
import metadataPlugin from './rollup-metadata-plugin'
import pkg from '../package.json' assert { type: 'json' }
const pkg = JSON.parse(
fs.readFileSync(new URL('../package.json', import.meta.url).pathname).toString()
)

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const EXTENSIONS = ['', '.ts', '.js']
Expand Down Expand Up @@ -73,7 +76,9 @@ const config: rollup.RollupOptions[] = [
types: `${path.basename(output)}.d.ts`,
dependencies: {
...Object.fromEntries(
Object.entries(pkg.dependencies).filter(([key]) => directDependencies.has(key))
Object.entries(pkg.dependencies as Record<string, string>).filter(([key]) =>
directDependencies.has(key)
)
)
}
}
Expand Down

0 comments on commit b66efc8

Please sign in to comment.