Skip to content

Commit

Permalink
fix: add ESM support by replacing __dirname
Browse files Browse the repository at this point in the history
Introduced treatAsEsm input to handle ESM transformation.
  • Loading branch information
gentlementlegen committed Nov 7, 2024
1 parent 789e396 commit b722932
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
nodeVersion:
description: "The version of Node.js to use."
default: "20.10.0"
treatAsEsm:
description: "If the package is set to be treated as ESM, it will replace __dirname occurrences."
default: false
outputs: {}
runs:
using: "composite"
Expand All @@ -42,10 +45,18 @@ runs:
run: |
yarn add -DE @vercel/ncc
echo "Compiling plugin..."
yarn ncc build --minify ${{ inputs.pluginEntry }} -m -o dist
yarn ncc build ${{ inputs.pluginEntry }} -m -o dist
echo "Compiling plugin types..."
yarn ncc build ${{ inputs.schemaPath }} -m -o plugin
- name: Replace __dirname with import.meta.dirname
if: ${{ inputs.treatAsEsm }}
shell: bash
run: |
if [ "${{ inputs.treatAsEsm }}" = "true" ]; then
sed -i '' 's/__dirname/import.meta.dirname/g' "${{ github.workspace }}/dist/index.js"
fi
- name: Update manifest configuration JSON
uses: actions/github-script@v7
with:
Expand Down

0 comments on commit b722932

Please sign in to comment.