-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
177 additions
and
89 deletions.
There are no files selected for viewing
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,24 @@ | ||
name: Publish | ||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+*' | ||
|
||
jobs: | ||
npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 22 | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
- run: npm run publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Publish Release | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
GH_REPO: ${{ github.repository }} | ||
run: gh release edit "${{ needs.release.outputs.tag }}" --draft=false |
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,6 @@ | ||
# Changelog | ||
|
||
## v2.2.0 - 2024-09-01 | ||
|
||
- Updated swc-core dependency to v1.7.20; | ||
- Replaced some external dependencies with the internal implementation. |
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,69 @@ | ||
const path = require('path'); | ||
const SourceMapGenerator = require('source-map').SourceMapGenerator; | ||
const SourceMapConsumer = require('source-map').SourceMapConsumer; | ||
|
||
function startsWithSingleDot(fpath) { | ||
const first2chars = fpath.slice(0, 2); | ||
return first2chars === '.' + path.sep || first2chars === './'; | ||
} | ||
|
||
function replace(npath, ext) { | ||
if (typeof npath !== 'string' || npath.length === 0) { | ||
return npath; | ||
} | ||
|
||
const nFileName = path.basename(npath, path.extname(npath)) + ext; | ||
const nFilepath = path.join(path.dirname(npath), nFileName); | ||
|
||
if (startsWithSingleDot(npath)) { | ||
return '.' + path.sep + nFilepath; | ||
} | ||
return nFilepath; | ||
} | ||
|
||
function replaceExtension(fp) { | ||
return path.extname(fp) ? replace(fp, '.js') : fp; | ||
} | ||
|
||
function applySourceMap(file, sourceMap) { | ||
if (typeof sourceMap === 'string' || sourceMap instanceof String) { | ||
sourceMap = JSON.parse(sourceMap); | ||
} | ||
|
||
if (file.sourceMap && (typeof file.sourceMap === 'string' || file.sourceMap instanceof String)) { | ||
file.sourceMap = JSON.parse(file.sourceMap); | ||
} | ||
|
||
// check source map properties | ||
assertProperty(sourceMap, "file"); | ||
assertProperty(sourceMap, "mappings"); | ||
assertProperty(sourceMap, "sources"); | ||
|
||
// fix paths if Windows style paths | ||
sourceMap.file = sourceMap.file.replace(/\\/g, '/'); | ||
sourceMap.sources = sourceMap.sources.map(function(filePath) { | ||
return filePath.replace(/\\/g, '/'); | ||
}); | ||
|
||
if (file.sourceMap && file.sourceMap.mappings !== '') { | ||
const generator = SourceMapGenerator.fromSourceMap(new SourceMapConsumer(sourceMap)); | ||
generator.applySourceMap(new SourceMapConsumer(file.sourceMap)); | ||
file.sourceMap = JSON.parse(generator.toString()); | ||
} else { | ||
file.sourceMap = sourceMap; | ||
} | ||
}; | ||
|
||
|
||
function assertProperty(sourceMap, propertyName) { | ||
if (!sourceMap.hasOwnProperty(propertyName)) { | ||
const e = new Error('Source map to be applied is missing the \"' + propertyName + '\" property'); | ||
throw e; | ||
} | ||
} | ||
|
||
|
||
module.exports = { | ||
replaceExtension, | ||
applySourceMap | ||
} |
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
Oops, something went wrong.