-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: Migrate repository to ESM
BREAKING CHANGE: The repository is now marked as ESM. From the end-use perspective this shouldn't cause any problems itself, but if you run into any issues, keep this in mind.
- Loading branch information
Showing
18 changed files
with
88 additions
and
56 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains 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 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,3 +1,2 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../scripts/postinstall.js'); | ||
import '../scripts/postinstall.js'; |
This file contains 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,3 +1,2 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../scripts/switch-cli.js'); | ||
import '../scripts/switch-cli.js'; |
This file contains 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,5 +1,6 @@ | ||
{ | ||
"name": "vue2-builder", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "MIT", | ||
|
This file contains 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 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,5 +1,6 @@ | ||
{ | ||
"name": "vue3-builder", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "MIT", | ||
|
This file contains 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 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,5 +1,6 @@ | ||
{ | ||
"name": "@morev/vue-modals-nuxt", | ||
"type": "module", | ||
"private": "true", | ||
"exports": { | ||
".": { | ||
|
This file contains 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 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 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 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 @@ | ||
const fs = require('fs'); | ||
import { readFileSync, writeFileSync } from 'node:fs'; | ||
|
||
const packageJsonContents = fs.readFileSync('package.json', { encoding: 'utf8' }); | ||
const packageJsonContents = readFileSync('package.json', { encoding: 'utf8' }); | ||
|
||
fs.writeFileSync( | ||
writeFileSync( | ||
'package.json', | ||
packageJsonContents.replace('"private": false', '"private": true'), | ||
); |
This file contains 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,12 +1,11 @@ | ||
const fs = require('fs'); | ||
import { readFileSync, writeFileSync } from 'node:fs'; | ||
|
||
const packageJsonContents = fs.readFileSync('package.json', { encoding: 'utf8' }); | ||
const packageJsonContents = readFileSync('package.json', { encoding: 'utf8' }); | ||
|
||
fs.writeFileSync( | ||
writeFileSync( | ||
'package.json', | ||
packageJsonContents | ||
.replace('"private": true', '"private": false') | ||
.replace('"scripts": {', '"scripts": {\n\t\t"postinstall": "node ./scripts/postinstall.js",') | ||
// eslint-disable-next-line regexp/strict | ||
.replaceAll(/"workspaces": \[[^\]]*],\s*/g, ''), | ||
); |
This file contains 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,14 +1,12 @@ | ||
const { switchVersion, ERROR_PREFIX } = require('./utils.js'); | ||
import { switchVersion, ERROR_PREFIX } from './utils.js'; | ||
|
||
const version = process.argv[2]; | ||
const vueEntry = process.argv[3] || 'vue'; | ||
|
||
if (version === '2') { | ||
switchVersion(2, vueEntry); | ||
console.log(`${ERROR_PREFIX} Switched for Vue 2 (entry: "${vueEntry}")`); | ||
} else if (version === '3') { | ||
switchVersion(3, vueEntry); | ||
console.log(`${ERROR_PREFIX} Switched for Vue 3 (entry: "${vueEntry}")`); | ||
} else { | ||
console.warn(`${ERROR_PREFIX} expecting version "2" or "3" but got "${version}"`); | ||
} |
This file contains 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,34 +1,36 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
import { readFileSync, writeFileSync, unlinkSync } from 'node:fs'; | ||
import { dirname, resolve, join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
const dir = path.resolve(__dirname); | ||
const dir = resolve(dirname(fileURLToPath(import.meta.url))); | ||
|
||
const loadModule = (name) => { | ||
const copy = (name, version) => { | ||
const source = join(dir, '..', 'dist', `vue${version}`, name); | ||
const destination = join(dir, '..', 'dist', name); | ||
|
||
const content = readFileSync(source, 'utf8'); | ||
|
||
// unlink for pnpm, @see https://github.com/vueuse/vue-demi/issues/92 | ||
try { unlinkSync(destination); } catch {} | ||
|
||
writeFileSync(destination, content, 'utf8'); | ||
}; | ||
|
||
export const ERROR_PREFIX = '[@morev/vue-transitions]'; | ||
|
||
export const loadModule = async (name) => { | ||
try { | ||
return require(name); | ||
return import(name); | ||
} catch { | ||
return undefined; | ||
} | ||
}; | ||
|
||
const copy = (name, version) => { | ||
const src = path.join(dir, '..', 'dist', `vue${version}`, name); | ||
const dest = path.join(dir, '..', 'dist', name); | ||
const content = fs.readFileSync(src, 'utf8'); | ||
// unlink for pnpm, @see https://github.com/vueuse/vue-demi/issues/92 | ||
try { | ||
fs.unlinkSync(dest); | ||
} catch {} | ||
fs.writeFileSync(dest, content, 'utf8'); | ||
}; | ||
|
||
const switchVersion = (version) => { | ||
copy('vue-transitions.cjs.js', version); | ||
copy('vue-transitions.es.js', version); | ||
export const switchVersion = (version, vueEntry = 'vue') => { | ||
copy('vue-transitions.cjs', version); | ||
copy('vue-transitions.js', version); | ||
copy('vue-transitions.umd.js', version); | ||
copy('index.css', version); | ||
}; | ||
|
||
module.exports.loadModule = loadModule; | ||
module.exports.switchVersion = switchVersion; | ||
module.exports.ERROR_PREFIX = '[@morev/vue-transitions]'; | ||
console.log(`${ERROR_PREFIX} Switched for Vue ${version} (entry: '${vueEntry}')`); | ||
}; |
This file contains 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 @@ | ||
import './index.d.ts'; |