Skip to content

Commit f3c3c80

Browse files
committed
chore: move repo to ESM
1 parent 011be15 commit f3c3c80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+130
-68
lines changed

.eslintrc.js .eslintrc.cjs

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict'
22

33
module.exports = {
4-
'no-render-string-reference': require('./scripts/rules/no-render-string-reference'),
5-
'no-components-index': require('./scripts/rules/no-components-index'),
6-
'jsx-condition-key': require('./scripts/rules/jsx-condition-key'),
7-
'jsx-curly-spacing': require('./scripts/rules/jsx-curly-spacing'),
8-
'vitest-global-imports': require('./scripts/rules/vitest-global-imports'),
9-
'sort-imports': require('./scripts/rules/sort-imports'),
10-
'no-nullish-coalescing-in-condition': require('./scripts/rules/no-nullish-coalescing-in-condition'),
4+
'no-render-string-reference': require('./scripts/rules/no-render-string-reference.cjs'),
5+
'no-components-index': require('./scripts/rules/no-components-index.cjs'),
6+
'jsx-condition-key': require('./scripts/rules/jsx-condition-key.cjs'),
7+
'jsx-curly-spacing': require('./scripts/rules/jsx-curly-spacing.cjs'),
8+
'vitest-global-imports': require('./scripts/rules/vitest-global-imports.cjs'),
9+
'sort-imports': require('./scripts/rules/sort-imports.cjs'),
10+
'no-nullish-coalescing-in-condition': require('./scripts/rules/no-nullish-coalescing-in-condition.cjs'),
1111
}

jest.config.js jest.config.cjs

File renamed without changes.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@vuetify/vuetify-root",
3+
"type": "module",
34
"private": true,
45
"husky": {
56
"hooks": {

packages/api-generator/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@vuetify/api-generator",
3+
"type": "module",
34
"version": "3.7.16",
45
"private": true,
56
"description": "",

packages/api-generator/src/helpers/sass.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs'
1+
import fs from 'node:fs'
22

33
function processVariableFile (filePath: string) {
44
if (fs.existsSync(filePath)) {

packages/api-generator/src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import fs from 'fs/promises'
1+
import fs from 'node:fs/promises'
22
import path from 'upath'
3-
import { components } from 'vuetify/dist/vuetify-labs.js'
43
import importMap from 'vuetify/dist/json/importMap.json' with { type: 'json' }
54
import importMapLabs from 'vuetify/dist/json/importMap-labs.json' with { type: 'json' }
65
import { kebabCase } from './helpers/text'
@@ -17,6 +16,10 @@ import inspector from 'inspector'
1716
import yargs from 'yargs'
1817
import { parseSassVariables } from './helpers/sass'
1918

19+
import { createRequire } from 'node:module'
20+
21+
const { components } = createRequire(import.meta.url)('vuetify/dist/vuetify-labs.js')
22+
2023
const yar = yargs(process.argv.slice(2))
2124
.option('components', {
2225
type: 'array',

packages/api-generator/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { execSync } from 'child_process'
1+
import { execSync } from 'node:child_process'
22
import stringifyObject from 'stringify-object'
33
import prettier from 'prettier'
44
import * as typescriptParser from 'prettier/plugins/typescript'

packages/api-generator/src/vetur.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs'
1+
import fs from 'node:fs'
22
import { kebabCase } from './helpers/text'
33
import type { ComponentData } from './types'
44

packages/api-generator/src/web-types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs'
1+
import fs from 'node:fs'
22
import { capitalize } from './helpers/text'
33
import type { ComponentData, DirectiveData } from './types'
44
import pkg from '../package.json' with { type: 'json' }
File renamed without changes.

packages/docs/build/examples-plugin.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Plugin } from 'vite'
2-
import path from 'path'
3-
import fs from 'fs/promises'
4-
import { fileURLToPath } from 'url'
2+
import path from 'node:path'
3+
import fs from 'node:fs/promises'
4+
import { fileURLToPath } from 'node:url'
55

66
const ID = '@vuetify-examples'
77

File renamed without changes.

packages/docs/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "vuetifyjs.com",
3+
"type": "module",
34
"description": "A Vue.js project",
45
"private": true,
56
"author": "John Leider <[email protected]>",

packages/docs/vite.config.mts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'upath'
2-
import fs from 'fs/promises'
3-
import { fileURLToPath } from 'url'
2+
import fs from 'node:fs/promises'
3+
import { fileURLToPath } from 'node:url'
44

55
import { defineConfig, loadEnv } from 'vite'
66
import AutoImport from 'unplugin-auto-import/vite'

packages/vuetify/build/constants.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import packageJson from '../package.json' with { type: 'json' }
2+
import path from 'upath'
3+
import { fileURLToPath } from 'node:url'
4+
5+
export const banner = `/*!
6+
* Vuetify v${packageJson.version}
7+
* Forged by John Leider
8+
* Released under the MIT License.
9+
*/\n`
10+
11+
export const root = path.resolve(fileURLToPath(import.meta.url), '../..')
12+
export const srcDir = path.resolve(root, 'src')
13+
export const libDir = path.resolve(root, 'lib')
14+
export const unpluginLibDistDir = path.resolve(libDir, 'unplugin')
15+
export const labsDir = path.resolve(srcDir, 'labs')
16+
17+
export const externals = Array.from(Object.keys(packageJson.devDependencies))

packages/vuetify/build/rollup.config.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'upath'
22
import { mkdirp } from 'mkdirp'
3-
import { writeFile } from 'fs/promises'
4-
import { fileURLToPath } from 'url'
3+
import { writeFile } from 'node:fs/promises'
4+
import { fileURLToPath } from 'node:url'
55

66
import packageJson from '../package.json' with { type: 'json' }
77

@@ -15,20 +15,18 @@ import autoprefixer from 'autoprefixer'
1515
import cssnano from 'cssnano'
1616
import postcss from 'postcss'
1717
import { simple as walk } from 'acorn-walk'
18+
import {
19+
banner,
20+
labsDir,
21+
libDir,
22+
root,
23+
srcDir,
24+
} from './constants.js'
1825

1926
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.es6', '.es', '.mjs']
20-
const banner = `/*!
21-
* Vuetify v${packageJson.version}
22-
* Forged by John Leider
23-
* Released under the MIT License.
24-
*/\n`
2527

26-
const root = path.resolve(fileURLToPath(import.meta.url), '../..')
27-
const srcDir = path.resolve(root, 'src')
28-
const libDir = path.resolve(root, 'lib')
29-
const labsDir = path.resolve(srcDir, 'labs')
30-
31-
export default [
28+
/** @type {import("rollup").RollupOptions[]} */
29+
const options = [
3230
{
3331
input: 'src/entry-bundler.ts',
3432
output: [
@@ -294,3 +292,5 @@ export default [
294292
],
295293
},
296294
]
295+
296+
export default options

packages/vuetify/build/rollup.types.config.js

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs from 'fs/promises'
2-
import { fileURLToPath } from 'url'
1+
import fs from 'node:fs/promises'
2+
import { fileURLToPath } from 'node:url'
33

44
import dts from 'rollup-plugin-dts'
55
import fg from 'fast-glob'
@@ -9,6 +9,10 @@ import MagicString from 'magic-string'
99
import importMap from '../dist/json/importMap.json' with { type: 'json' }
1010
import importMapLabs from '../dist/json/importMap-labs.json' with { type: 'json' }
1111

12+
/**
13+
* @param code {string}
14+
* @returns {string}
15+
*/
1216
export function codeTransform (code) {
1317
return code
1418
// ignore missing vue-router
@@ -17,6 +21,13 @@ export function codeTransform (code) {
1721
.replaceAll(/^\s*export \{\s*\};?$/gm, '')
1822
}
1923

24+
/**
25+
* @param input {string}
26+
* @param output {string}
27+
* @param renderChunk {import("rollup").RenderChunkHook | undefined}
28+
* @param filter {(files: string[]) => string[] | undefined}
29+
* @returns {import("rollup").RollupOptions[]}
30+
*/
2031
function createTypesConfig (input, output, renderChunk, filter) {
2132
input = 'lib/' + input
2233
let files = fg.sync(input)
@@ -25,7 +36,8 @@ function createTypesConfig (input, output, renderChunk, filter) {
2536

2637
return files.map(file => {
2738
const outputFile = output.replace('*', mm.capture(input, file)[0])
28-
return {
39+
/** @type {import("rollup").RollupOptions} */
40+
const options = {
2941
input: file,
3042
output: [{ file: outputFile, format: 'es', sourcemap: false }],
3143
plugins: [
@@ -51,9 +63,14 @@ function createTypesConfig (input, output, renderChunk, filter) {
5163
},
5264
],
5365
}
66+
return options
5467
})
5568
}
5669

70+
/**
71+
* @param useImport {boolean|undefined}
72+
* @returns {Promise<string>}
73+
*/
5774
async function getShims (useImport) {
5875
let components
5976
if (useImport) {
@@ -75,7 +92,8 @@ async function getShims (useImport) {
7592
.replace(/^\s*\/\/ @generate-components$/gm, components)
7693
}
7794

78-
export default [
95+
/** @type {import("rollup").RollupOptions[]} */
96+
const options = [
7997
createTypesConfig('entry-bundler.d.ts', 'dist/vuetify.d.ts', async code => {
8098
code.replaceAll(/type index_d\$1_V(\w+) = V(\w+);/gm, 'declare const index_d$$1_V$1: typeof V$2;')
8199
code.append('\n\n')
@@ -91,3 +109,5 @@ export default [
91109
code.append(await getShims(true))
92110
}),
93111
].flat()
112+
113+
export default options

packages/vuetify/src/locale/__tests__/index.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Utilities
2-
import fs from 'fs'
3-
import path from 'path'
2+
import fs from 'node:fs'
3+
import path from 'node:path'
44
import * as locales from '../'
55

66
describe('locales', () => {

packages/vuetify/vite.config.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import path from 'path'
2-
import fs, { readFileSync } from 'fs'
3-
import { fileURLToPath } from 'url'
1+
import path from 'node:path'
2+
import fs, { readFileSync } from 'node:fs'
3+
import { fileURLToPath } from 'node:url'
44

55
import fg from 'fast-glob'
66
import { defineConfig, loadEnv } from 'vite'
@@ -34,12 +34,12 @@ export default defineConfig(({ mode }) => {
3434
root: resolve('dev'),
3535
server: {
3636
host: process.env.HOST,
37-
port: process.env.TEST ? undefined : +(process.env.PORT ?? 8090),
37+
port: process.env.TEST ? undefined : Number(process.env.PORT ?? 8090),
3838
strictPort: !!process.env.PORT && !process.env.TEST,
3939
},
4040
preview: {
4141
host: process.env.HOST,
42-
port: +(process.env.PORT ?? 8090),
42+
port: Number(process.env.PORT ?? 8090),
4343
strictPort: !!process.env.PORT,
4444
},
4545
resolve: {

packages/vuetify/vitest.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig, mergeConfig } from 'vitest/config'
22
import viteConfig from './vite.config'
33
import AutoImport from 'unplugin-auto-import/vite'
4-
import { fileURLToPath } from 'url'
4+
import { fileURLToPath } from 'node:url'
55

66
const IS_RUN = process.argv.slice(2).some(v => v === 'run')
77

packages/vuetify/vitest.workspace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineWorkspace } from 'vitest/config'
22
import { commands } from './test/setup/browser-commands'
3-
import { fileURLToPath } from 'url'
3+
import { fileURLToPath } from 'node:url'
44

55
export default defineWorkspace([
66
{

scripts/build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const spawn = require('cross-spawn')
1+
import { spawn } from 'cross-spawn'
22

33
let target = process.argv[2]
44
const alias = {

scripts/confirm-npm-tag.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
const semver = require('semver')
2-
const shell = require('shelljs')
3-
const inquirer = require('inquirer')
4-
const version = require('../lerna.json').version
1+
import semver from 'semver'
2+
import shell from 'shelljs'
3+
import inquirer from 'inquirer'
4+
import lerna from '../lerna.json' with { type: 'json' }
55

66
if (process.env.CI) process.exit(0)
77

8+
/**
9+
* @param command {string}
10+
* @returns {string}
11+
*/
812
function exec (command) {
913
const result = shell.exec(command, { silent: true })
1014
if (result.code) {
@@ -16,9 +20,9 @@ function exec (command) {
1620
}
1721

1822
const branch = exec('git symbolic-ref --short HEAD')
19-
const tag = semver.prerelease(version) == null ? 'latest' : branch
23+
const tag = semver.prerelease(lerna.version) == null ? 'latest' : branch
2024

21-
shell.echo(`Releasing ${version} on ${branch}`)
25+
shell.echo(`Releasing ${lerna.version} on ${branch}`)
2226
shell.echo(`Tag: ${tag}`)
2327
inquirer.prompt({
2428
type: 'confirm',

scripts/converter.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// Utilities
2-
const fs = require('fs')
3-
const path = require('path')
4-
const glob = require('glob')
5-
const stringify = require('stringify-object')
6-
const resolve = file => path.resolve(__dirname, file)
2+
import fs from 'node:fs'
3+
import path from 'node:path'
4+
import glob from 'glob'
5+
import stringify from 'stringify-object'
6+
import url from 'node:url'
7+
8+
const root = path.dirname(url.fileURLToPath(import.meta.url))
9+
const resolve = file => path.resolve(root, file)
710

811
const snippetsUsed = new Set()
912

scripts/dev.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const spawn = require('cross-spawn')
1+
import { spawn } from 'cross-spawn'
22

33
let target = process.argv[2]
44
const alias = {

scripts/lint-commit-message.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fs = require('fs')
1+
import fs from 'node:fs'
22

33
const reset = '\x1b[0m'
44
const red = '\x1b[31m'
@@ -8,6 +8,10 @@ const currentMessage = fs.readFileSync(messageFile, 'utf8').replace(/^# --------
88

99
const errors = []
1010

11+
/**
12+
* @param message {string}
13+
* @param cb {(currentMessage: string) => boolean}
14+
*/
1115
function check (message, cb) {
1216
if (cb(currentMessage)) {
1317
errors.push(message)

scripts/options-to-composition.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs from 'fs/promises'
2-
import path from 'path'
1+
import fs from 'node:fs/promises'
2+
import path from 'node:path'
33
import { ESLint } from 'eslint'
44
import { convertSrc } from 'vue-composition-converter'
55

scripts/parse-npm-tag.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const semver = require('semver')
1+
import semver from 'semver'
22

33
const version = process.argv[2]
44

scripts/post-install.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
const shell = require('shelljs')
2-
const fs = require('fs')
3-
const path = require('path')
4-
const resolve = target => path.resolve(__dirname, target)
1+
import shell from 'shelljs'
2+
import fs from 'node:fs'
3+
import path from 'node:path'
4+
import url from 'node:url'
5+
6+
const root = path.dirname(url.fileURLToPath(import.meta.url))
7+
const resolve = target => path.resolve(root, target)
8+
59
const devTargetFolder = '../packages/vuetify/dev'
610
const devTargetFile = `${devTargetFolder}/Playground.vue`
711

0 commit comments

Comments
 (0)