Skip to content

Commit fa13163

Browse files
committed
build: switch to modules
1 parent acf67aa commit fa13163

File tree

7 files changed

+34
-31
lines changed

7 files changed

+34
-31
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"node": true
66
},
77
"parserOptions": {
8-
"ecmaVersion": 2019
8+
"ecmaVersion": 2020,
9+
"sourceType": "module"
910
},
1011
"extends": "eslint:recommended",
1112
"rules": {

build/build-pages.js renamed to build/build-pages.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/usr/bin/env node
22

3-
'use strict'
3+
import fs from 'node:fs/promises'
4+
import path from 'node:path'
5+
import { fileURLToPath } from 'node:url'
6+
import picocolors from 'picocolors'
47

5-
const fs = require('node:fs').promises
6-
const path = require('node:path')
7-
const picocolors = require('picocolors')
8+
const __filename = fileURLToPath(import.meta.url)
9+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
810

911
const iconsDir = path.join(__dirname, '../icons/')
1012
const pagesDir = path.join(__dirname, '../docs/content/icons/')

build/build-svgs.js renamed to build/build-svgs.mjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#!/usr/bin/env node
22

3-
'use strict'
3+
import fs from 'node:fs/promises'
4+
import path from 'node:path'
5+
import process from 'node:process'
6+
import { fileURLToPath } from 'node:url'
7+
import picocolors from 'picocolors'
8+
import { loadConfig, optimize } from 'svgo'
49

5-
const fs = require('node:fs').promises
6-
const path = require('node:path')
7-
const process = require('node:process')
8-
const picocolors = require('picocolors')
9-
const { loadConfig, optimize } = require('svgo')
10+
const __filename = fileURLToPath(import.meta.url)
11+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1012

1113
const iconsDir = path.join(__dirname, '../icons/')
1214

@@ -40,7 +42,7 @@ async function processFile(file, config) {
4042
console.time(timeLabel)
4143

4244
const files = await fs.readdir(iconsDir)
43-
const config = await loadConfig(path.join(__dirname, '../svgo.config.js'))
45+
const config = await loadConfig(path.join(__dirname, '../svgo.config.mjs'))
4446

4547
await Promise.all(files.map(file => processFile(file, config)))
4648

build/check-icons.js renamed to build/check-icons.mjs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env node
22

3-
'use strict'
4-
5-
const fs = require('node:fs').promises
6-
const path = require('node:path')
7-
const process = require('node:process')
8-
const picocolors = require('picocolors')
3+
import fs from 'node:fs/promises'
4+
import path from 'node:path'
5+
import process from 'node:process'
6+
import { fileURLToPath } from 'node:url'
7+
import picocolors from 'picocolors'
8+
9+
const __filename = fileURLToPath(import.meta.url)
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
911

1012
const fontJsonPath = path.join(__dirname, '../font/bootstrap-icons.json')
1113
const iconsDir = path.join(__dirname, '../icons/')

build/vnu-jar.js renamed to build/vnu-jar.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
77
*/
88

9-
'use strict'
10-
11-
const { execFile, spawn } = require('node:child_process')
12-
const vnu = require('vnu-jar')
9+
import { execFile, spawn } from 'node:child_process'
10+
import vnu from 'vnu-jar'
1311

1412
execFile('java', ['-version'], (error, stdout, stderr) => {
1513
if (error) {

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020
"start": "npm run docs-serve",
2121
"docs-serve": "hugo server --port 4000 --disableFastRender",
2222
"docs-build": "hugo --cleanDestinationDir --printUnusedTemplates",
23-
"pages": "node build/build-pages.js",
23+
"pages": "node build/build-pages.mjs",
2424
"icons": "npm-run-all icons-main --aggregate-output --parallel icons-sprite icons-font",
25-
"icons-main": "node build/build-svgs.js",
25+
"icons-main": "node build/build-svgs.mjs",
2626
"icons-zip": "cross-env-shell \"rm -rf bootstrap-icons-$npm_package_version bootstrap-icons-$npm_package_version.zip && cp -r icons/ bootstrap-icons-$npm_package_version && cp bootstrap-icons.svg bootstrap-icons-$npm_package_version && cp -r font/ bootstrap-icons-$npm_package_version && zip -qr9 bootstrap-icons-$npm_package_version.zip bootstrap-icons-$npm_package_version && rm -rf bootstrap-icons-$npm_package_version\"",
2727
"icons-sprite": "svg-sprite --config svg-sprite.json --log=info icons/*.svg",
2828
"icons-font": "fantasticon",
2929
"release": "npm-run-all icons docs-build icons-zip",
3030
"netlify": "cross-env-shell HUGO_BASEURL=$DEPLOY_PRIME_URL npm-run-all icons docs-build",
3131
"test:fusv": "fusv docs/assets/scss/",
32-
"test:eslint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives .",
32+
"test:eslint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives --ext .js,.mjs .",
3333
"test:stylelint": "stylelint docs/assets/scss/ --cache --cache-location node_modules/.cache/.stylelintcache --rd",
3434
"test:lockfile-lint": "lockfile-lint --allowed-hosts npm --allowed-schemes https: --empty-hostname false --type npm --path package-lock.json",
35-
"test:vnu": "node build/vnu-jar.js",
36-
"test:check-icons": "node build/check-icons.js",
35+
"test:vnu": "node build/vnu-jar.mjs",
36+
"test:check-icons": "node build/check-icons.mjs",
3737
"test": "npm-run-all docs-build --parallel --aggregate-output --continue-on-error test:*"
3838
},
3939
"style": "font/bootstrap-icons.css",

svgo.config.js renamed to svgo.config.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict'
1+
import path from 'node:path'
22

3-
const path = require('node:path')
4-
5-
module.exports = {
3+
export default {
64
multipass: true,
75
js2svg: {
86
pretty: true,

0 commit comments

Comments
 (0)