diff --git a/plugins/plugin-svgattr/build.mjs b/plugins/plugin-svgattr/build.mjs index 9d1da1994da..0f283af1c6d 100644 --- a/plugins/plugin-svgattr/build.mjs +++ b/plugins/plugin-svgattr/build.mjs @@ -14,7 +14,7 @@ const banner = `/** const options = { banner: { js: banner }, bundle: true, - entryPoints: ['src/index.js'], + entryPoints: ['src/index.mjs'], format: 'esm', outfile: 'dist/index.mjs', external: ["@freesewing"], diff --git a/plugins/plugin-svgattr/package.json b/plugins/plugin-svgattr/package.json index 40bbb9c35cd..b456a7fbcb3 100644 --- a/plugins/plugin-svgattr/package.json +++ b/plugins/plugin-svgattr/package.json @@ -38,7 +38,7 @@ "vbuild": "VERBOSE=1 node --experimental-json-modules build.mjs", "lab": "cd ../../sites/lab && yarn start", "tips": "node ../../scripts/help.mjs", - "prettier": "npx prettier --write 'src/*.js' 'tests/*.mjs'", + "prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'", "testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js", "cibuild_step1": "node --experimental-json-modules build.mjs" }, diff --git a/plugins/plugin-svgattr/src/index.js b/plugins/plugin-svgattr/src/index.js deleted file mode 100644 index e24529ca7a6..00000000000 --- a/plugins/plugin-svgattr/src/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import pkg from '../package.json' - -export default { - name: pkg.name, - version: pkg.version, - hooks: { - preRender: function (svg, attributes = {}) { - if (svg.attributes.get('freesewing:plugin-svgattr') === false) { - for (const key of Object.keys(attributes)) svg.attributes.add(key, attributes[key]) - svg.attributes.add('freesewing:plugin-svgattr', pkg.version) - } - }, - }, -} diff --git a/plugins/plugin-svgattr/src/index.mjs b/plugins/plugin-svgattr/src/index.mjs new file mode 100644 index 00000000000..5666b3b57d8 --- /dev/null +++ b/plugins/plugin-svgattr/src/index.mjs @@ -0,0 +1,16 @@ +import { name, version } from '../package.json' + +export const plugin = { + name, + version, + hooks: { + preRender: function (svg, attributes = {}) { + for (const key of Object.keys(attributes)) svg.attributes.set(key, attributes[key]) + }, + }, +} + +// More specifically named exports +export const bannerPlugin = plugin +export const pluginBanner = plugin + diff --git a/plugins/plugin-svgattr/tests/plugin.test.mjs b/plugins/plugin-svgattr/tests/plugin.test.mjs index 6fb1fdfbd44..ea337fafa1d 100644 --- a/plugins/plugin-svgattr/tests/plugin.test.mjs +++ b/plugins/plugin-svgattr/tests/plugin.test.mjs @@ -1,6 +1,4 @@ import chai from 'chai' -//import freesewing from '@freesewing/core' -//import plugin from '../dist/index.mjs' const expect = chai.expect; diff --git a/plugins/plugin-svgattr/tests/shared.test.mjs b/plugins/plugin-svgattr/tests/shared.test.mjs index 9638f75571e..fdf846844b0 100644 --- a/plugins/plugin-svgattr/tests/shared.test.mjs +++ b/plugins/plugin-svgattr/tests/shared.test.mjs @@ -1,8 +1,7 @@ -// This file is auto-generated. -// Changes you make will be overwritten. -import plugin from './dist/index.mjs' +// This file is auto-generated | Any changes you make will be overwritten. +import { plugin } from './dist/index.mjs' import { sharedPluginTests } from '../../../tests/plugins/shared.mjs' - // Run shared tests sharedPluginTests(plugin) +