Skip to content

Commit

Permalink
Fix domino require in turndown build script
Browse files Browse the repository at this point in the history
  • Loading branch information
tztsai committed Nov 11, 2024
1 parent 3523d09 commit 6c77f31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions build/turndown/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ cd "$(dirname "$0")"
npm ci 2> /dev/null || npm i

# # turndown.min.js
# npx rollup --config rollup.mjs --input turndown.mjs --file turndown.js
npx rollup --config rollup.mjs --input turndown.mjs --file turndown.js

# # Replace the function containing `require` with the async function
# sed -i '/var domino = require('"'"'@mixmark-io\/domino'"'"');/ {
# N
# s/var domino = require('"'"'@mixmark-io\/domino'"'"');\n\s*Parser.prototype.parseFromString = function (string) {/Parser.prototype.parseFromString = async function (string) {\n var domino = await import("\/vendor\/domino.min.js");/
# }' turndown.js
# FIXIT: replace domino require with import
# awk '/var domino = require('\''@mixmark-io\/domino'\'');/ {
# printf "%s\n", $0
# getline
# printf "Parser.prototype.parseFromString = async function (string) {\n"
# printf " var domino = await import(\"\/vendor\/domino.min.js\");\n"
# next
# } { print }' turndown.js > turndown_temp.js && mv turndown_temp.js turndown.js

npx terser --compress --mangle -- turndown.js > ../../vendor/turndown.min.js

# after
rm -rf node_modules/
rm -rf node_modules/
1 change: 1 addition & 0 deletions build/turndown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"@rollup/plugin-node-resolve": "^15.3.0",
"browserify": "^17.0.1",
"rollup": "^4.25.0",
"terser": "^5.36.0",
"turndown": "^7.2.0"
}
}

0 comments on commit 6c77f31

Please sign in to comment.