Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: switch to magic-regexp #755

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@sapphire/prettier-config": "workspace:^",
"@vitest/coverage-v8": "^1.6.0",
"esbuild-plugin-file-path-extensions": "^2.1.1",
"magic-regexp": "^0.8.0",
"npm-run-all2": "^6.2.0",
"tsup": "^8.0.2",
"tsx": "^4.11.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/utilities/src/lib/regExpEsc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const REGEXPESC = /[-/\\^$*+?.()|[\]{}]/g;
import { charIn, createRegExp, global } from 'magic-regexp';

const REGEXPESC = createRegExp(charIn('-/\\^$*+?.()|[]{}'), [global]);

/**
* Cleans a string from regex injection
Expand Down
3 changes: 2 additions & 1 deletion packages/utilities/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { esbuildPluginFilePathExtensions } from 'esbuild-plugin-file-path-extensions';
import { MagicRegExpTransformPlugin } from 'magic-regexp/transform';
import { Options } from 'tsup';
import { createTsupConfig } from '../../scripts/tsup.config';

Expand All @@ -10,7 +11,7 @@ const cjsAndEsmOptions: Options = {
...options,
bundle: true,
entry: ['src/**/*.ts'],
esbuildPlugins: [esbuildPluginFilePathExtensions()]
esbuildPlugins: [esbuildPluginFilePathExtensions(), MagicRegExpTransformPlugin.esbuild()]
};

export default createTsupConfig({
Expand Down
64 changes: 61 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,7 @@ __metadata:
"@sapphire/prettier-config": "workspace:^"
"@vitest/coverage-v8": "npm:^1.6.0"
esbuild-plugin-file-path-extensions: "npm:^2.1.1"
magic-regexp: "npm:^0.8.0"
npm-run-all2: "npm:^6.2.0"
tsup: "npm:^8.0.2"
tsx: "npm:^4.11.0"
Expand Down Expand Up @@ -2420,7 +2421,7 @@ __metadata:
languageName: node
linkType: hard

"chokidar@npm:^3.5.1":
"chokidar@npm:^3.5.1, chokidar@npm:^3.6.0":
version: 3.6.0
resolution: "chokidar@npm:3.6.0"
dependencies:
Expand Down Expand Up @@ -4832,7 +4833,22 @@ __metadata:
languageName: node
linkType: hard

"magic-string@npm:^0.30.4, magic-string@npm:^0.30.5":
"magic-regexp@npm:^0.8.0":
version: 0.8.0
resolution: "magic-regexp@npm:0.8.0"
dependencies:
estree-walker: "npm:^3.0.3"
magic-string: "npm:^0.30.8"
mlly: "npm:^1.6.1"
regexp-tree: "npm:^0.1.27"
type-level-regexp: "npm:~0.1.17"
ufo: "npm:^1.4.0"
unplugin: "npm:^1.8.3"
checksum: 10/acb175161c5b57bad488ec54c7581eabd62a5ac08631322765ff8262add7e9c1ecd3aa0a025727041e08fc75ebb45b0dc1ec08e6b23b2fafdd7a5b3d9334172a
languageName: node
linkType: hard

"magic-string@npm:^0.30.4, magic-string@npm:^0.30.5, magic-string@npm:^0.30.8":
version: 0.30.10
resolution: "magic-string@npm:0.30.10"
dependencies:
Expand Down Expand Up @@ -5807,6 +5823,15 @@ __metadata:
languageName: node
linkType: hard

"regexp-tree@npm:^0.1.27":
version: 0.1.27
resolution: "regexp-tree@npm:0.1.27"
bin:
regexp-tree: bin/regexp-tree
checksum: 10/08c70c8adb5a0d4af1061bf9eb05d3b6e1d948c433d6b7008e4b5eb12a49429c2d6ca8e9106339a432aa0d07bd6e1bccc638d8f4ab0d045f3adad22182b300a2
languageName: node
linkType: hard

"require-directory@npm:^2.1.1":
version: 2.1.1
resolution: "require-directory@npm:2.1.1"
Expand Down Expand Up @@ -6852,6 +6877,13 @@ __metadata:
languageName: node
linkType: hard

"type-level-regexp@npm:~0.1.17":
version: 0.1.17
resolution: "type-level-regexp@npm:0.1.17"
checksum: 10/1f6047c6e8af947aa80befd24cf1e9a3fff654d3dea61c1c15feb9bac8c02cd73e29dbdd34f5d7880589755ce6de4de5d56c4f5b8e7b4836ad1bb909afa5f493
languageName: node
linkType: hard

"typedoc-json-parser@npm:^10.0.0":
version: 10.0.0
resolution: "typedoc-json-parser@npm:10.0.0"
Expand Down Expand Up @@ -6906,7 +6938,7 @@ __metadata:
languageName: node
linkType: hard

"ufo@npm:^1.5.3":
"ufo@npm:^1.4.0, ufo@npm:^1.5.3":
version: 1.5.3
resolution: "ufo@npm:1.5.3"
checksum: 10/2b30dddd873c643efecdb58cfe457183cd4d95937ccdacca6942c697b87a2c578232c25a5149fda85436696bf0fdbc213bf2b220874712bc3e58c0fb00a2c950
Expand Down Expand Up @@ -6975,6 +7007,18 @@ __metadata:
languageName: node
linkType: hard

"unplugin@npm:^1.8.3":
version: 1.10.1
resolution: "unplugin@npm:1.10.1"
dependencies:
acorn: "npm:^8.11.3"
chokidar: "npm:^3.6.0"
webpack-sources: "npm:^3.2.3"
webpack-virtual-modules: "npm:^0.6.1"
checksum: 10/d9819fad8a177c080f7f2b80744d633101935a8a6cc26b42e6a46648cccc1c5de83b7763233d56e11af53f34e6c5074816262897c9048a31e5d697bef5bb57e7
languageName: node
linkType: hard

"uri-js@npm:^4.2.2, uri-js@npm:^4.4.1":
version: 4.4.1
resolution: "uri-js@npm:4.4.1"
Expand Down Expand Up @@ -7177,6 +7221,20 @@ __metadata:
languageName: node
linkType: hard

"webpack-sources@npm:^3.2.3":
version: 3.2.3
resolution: "webpack-sources@npm:3.2.3"
checksum: 10/a661f41795d678b7526ae8a88cd1b3d8ce71a7d19b6503da8149b2e667fc7a12f9b899041c1665d39e38245ed3a59ab68de648ea31040c3829aa695a5a45211d
languageName: node
linkType: hard

"webpack-virtual-modules@npm:^0.6.1":
version: 0.6.1
resolution: "webpack-virtual-modules@npm:0.6.1"
checksum: 10/12a43ecdb910185c9d7e4ec19cc3b13bff228dae362e8a487c0bd292b393555e017ad16f771d5ce5b692d91d65b71a7bcd64763958d39066a5351ea325395539
languageName: node
linkType: hard

"whatwg-encoding@npm:^3.1.1":
version: 3.1.1
resolution: "whatwg-encoding@npm:3.1.1"
Expand Down
Loading