);
19 | });
20 | "
21 | `;
22 |
23 | exports[`qwik labeled macro 1`] = `
24 | "import { component$ } from "@builder.io/qwik";
25 | const Cmp = component$(()=>{});
26 | "
27 | `;
28 |
29 | exports[`qwik labeled macro in function expression 1`] = `
30 | "import { component$ } from "@builder.io/qwik";
31 | const ABC = component$(function() {});
32 | export const Cmp = component$(()=>{});
33 | "
34 | `;
35 |
36 | exports[`qwik labeled macro with value false 1`] = `
37 | "function Cmp() {}
38 | "
39 | `;
40 |
--------------------------------------------------------------------------------
/packages/webpack/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@macro-plugin/webpack",
3 | "version": "1.2.1",
4 | "description": "Macro plugins integration for webpack",
5 | "main": "dist/index.js",
6 | "module": "dist/index.mjs",
7 | "types": "dist/index.d.ts",
8 | "files": [
9 | "dist",
10 | "CHANGELOG.md"
11 | ],
12 | "scripts": {
13 | "build": "rollup -c ../../rollup.config.mjs"
14 | },
15 | "keywords": [
16 | "webpack",
17 | "macro",
18 | "macro-plugin"
19 | ],
20 | "homepage": "https://github.com/macro-plugin/macros/tree/main/packages/webpack",
21 | "repository": {
22 | "type": "git",
23 | "url": "https://github.com/macro-plugin/macros.git"
24 | },
25 | "dependencies": {
26 | "@macro-plugin/core": "1.2.0",
27 | "@macro-plugin/shared": "1.2.1"
28 | },
29 | "devDependencies": {
30 | "webpack": "^5.80.0"
31 | },
32 | "exports": {
33 | "./package.json": "./package.json",
34 | ".": {
35 | "require": "./dist/index.js",
36 | "import": "./dist/index.mjs",
37 | "types": "./dist/index.d.ts"
38 | }
39 | },
40 | "author": "Raven Satir",
41 | "license": "MIT"
42 | }
43 |
--------------------------------------------------------------------------------
/packages/cli/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/core/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/factory/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/jest/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/qwik/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/rollup/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/shared/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/solid/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/vite/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/vue/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/webpack/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/jest-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/node-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/vite-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/register/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/rollup-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/webpack-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Raven Satir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/rollup/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@macro-plugin/rollup",
3 | "version": "1.2.2",
4 | "description": "Macro plugins integration for rollup",
5 | "main": "dist/index.js",
6 | "module": "dist/index.mjs",
7 | "types": "dist/index.d.ts",
8 | "files": [
9 | "dist",
10 | "CHANGELOG.md"
11 | ],
12 | "scripts": {
13 | "build": "rollup -c ../../rollup.config.mjs"
14 | },
15 | "keywords": [
16 | "rollup",
17 | "macro",
18 | "macros",
19 | "macro-plugin"
20 | ],
21 | "homepage": "https://github.com/macro-plugin/macros/tree/main/packages/rollup",
22 | "repository": {
23 | "type": "git",
24 | "url": "https://github.com/macro-plugin/macros.git"
25 | },
26 | "dependencies": {
27 | "@macro-plugin/core": "1.2.0",
28 | "@macro-plugin/shared": "1.2.1"
29 | },
30 | "devDependencies": {
31 | "rollup": "^3.20.0"
32 | },
33 | "exports": {
34 | "./package.json": "./package.json",
35 | ".": {
36 | "require": "./dist/index.js",
37 | "import": "./dist/index.mjs",
38 | "types": "./dist/index.d.ts"
39 | }
40 | },
41 | "author": "Raven Satir",
42 | "license": "MIT"
43 | }
44 |
--------------------------------------------------------------------------------
/packages/jest/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@macro-plugin/jest",
3 | "version": "1.1.2",
4 | "description": "Macro Plugins integration for jest",
5 | "main": "dist/index.js",
6 | "types": "dist/index.d.ts",
7 | "files": [
8 | "dist",
9 | "CHANGELOG.md"
10 | ],
11 | "scripts": {
12 | "build": "rollup -c"
13 | },
14 | "keywords": [
15 | "jest",
16 | "macro",
17 | "macros",
18 | "macro-plugin"
19 | ],
20 | "homepage": "https://github.com/macro-plugin/macros/tree/main/packages/jest",
21 | "repository": {
22 | "type": "git",
23 | "url": "https://github.com/macro-plugin/macros.git"
24 | },
25 | "dependencies": {
26 | "@macro-plugin/core": "1.2.0",
27 | "@macro-plugin/shared": "1.2.1"
28 | },
29 | "devDependencies": {
30 | "@jest/create-cache-key-function": "^27.4.2",
31 | "@jest/transform": "^27.5.1",
32 | "jest": "^27.4.4",
33 | "pirates": "^4.0.5"
34 | },
35 | "exports": {
36 | "./package.json": "./package.json",
37 | ".": {
38 | "require": "./dist/index.js",
39 | "types": "./dist/index.d.ts"
40 | }
41 | },
42 | "author": "Raven Satir",
43 | "license": "MIT"
44 | }
45 |
--------------------------------------------------------------------------------
/packages/shared/README.md:
--------------------------------------------------------------------------------
1 | # @macro-plugin/shared
2 |
3 | Shared utils for internel and plugin usage.
4 |
5 | ## Installation
6 |
7 | ```sh
8 | # if you use npm
9 | npm i -D @macro-plugin/shared
10 | # if you use pnpm
11 | pnpm i -D @macro-plugin/shared
12 | # if you use yarn
13 | yarn add -D @macro-plugin/shared
14 | ```
15 |
16 | ## API
17 |
18 | ### `addHook`
19 |
20 | add a require hook
21 |
22 | ### `picomatch`
23 |
24 | picomatch file matcher
25 |
26 | ### `autoRequire`
27 |
28 | require or import a package
29 |
30 | ### `loadConfigFile`
31 |
32 | async loading `macros.config.js` or `macros.config.ts`.
33 |
34 | ### `loadConfigFileSync`
35 |
36 | sync loading `macros.config.js` or `macros.config.ts`.
37 |
38 | ### `writeDts`
39 |
40 | write dts to path, check if content is same first.
41 |
42 | ### `extractSwcOptions`
43 |
44 | extract swc options from all your defined options.
45 |
46 | ### `buildTransformOptions`
47 |
48 | load config file, then return `[swcOptions, macroOptions, configPath]`
49 |
50 | ### `extractInput`
51 |
52 | split `(file | pattern)[]` to `{ files, patterns }`
53 |
54 | ### `extractFiles`
55 |
56 | extract files from `(file | pattern)[]`
--------------------------------------------------------------------------------
/packages/vite/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@macro-plugin/vite",
3 | "version": "1.2.2",
4 | "description": "Macro plugins integration for vite",
5 | "main": "dist/index.js",
6 | "module": "dist/index.mjs",
7 | "types": "dist/index.d.ts",
8 | "files": [
9 | "dist",
10 | "CHANGELOG.md"
11 | ],
12 | "scripts": {
13 | "build": "rollup -c ../../rollup.config.mjs"
14 | },
15 | "keywords": [
16 | "vite",
17 | "vitejs",
18 | "vite-plugin",
19 | "macro",
20 | "macro-plugin"
21 | ],
22 | "homepage": "https://github.com/macro-plugin/macros/tree/main/packages/vite",
23 | "repository": {
24 | "type": "git",
25 | "url": "https://github.com/macro-plugin/macros.git"
26 | },
27 | "dependencies": {
28 | "@macro-plugin/core": "1.2.0",
29 | "@macro-plugin/shared": "1.2.1"
30 | },
31 | "devDependencies": {
32 | "vite": "^4.2.0"
33 | },
34 | "exports": {
35 | "./package.json": "./package.json",
36 | ".": {
37 | "require": "./dist/index.js",
38 | "import": "./dist/index.mjs",
39 | "types": "./dist/index.d.ts"
40 | }
41 | },
42 | "author": "Raven Satir",
43 | "license": "MIT"
44 | }
45 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | /** @type { import("eslint-config-standard") } */
2 | module.exports = {
3 | env: {
4 | browser: true,
5 | es2021: true,
6 | node: true,
7 | jest: true,
8 | },
9 | extends: ["standard"],
10 | parser: "@typescript-eslint/parser",
11 | parserOptions: {
12 | ecmaVersion: "latest",
13 | sourceType: "module",
14 | },
15 | plugins: ["@typescript-eslint"],
16 | rules: {
17 | "arrow-spacing": 2,
18 | camelcase: 1,
19 | "comma-dangle": 0,
20 | "comma-spacing": 2,
21 | eqeqeq: [2, "allow-null"],
22 | indent: [2, 2, { SwitchCase: 1 }],
23 | "no-console": 1,
24 | "no-labels": 0,
25 | "no-undef": 0,
26 | "no-var": 0,
27 | "no-redeclare": 0,
28 | "no-extra-parens": 0,
29 | "no-constant-condition": 1,
30 | "no-use-before-define": 0,
31 | "no-trailing-spaces": 2,
32 | "@typescript-eslint/no-unused-vars": 1,
33 | "@typescript-eslint/no-redeclare": 1,
34 | "@typescript-eslint/no-dupe-class-members": 2,
35 | "@typescript-eslint/no-use-before-define": 1,
36 | "object-curly-spacing": [2, "always"],
37 | quotes: [2, "double", { avoidEscape: true }],
38 | semi: [2, "never"],
39 | },
40 | }
41 |
--------------------------------------------------------------------------------
/packages/jest/rollup.config.mjs:
--------------------------------------------------------------------------------
1 | import commonjs from "@rollup/plugin-commonjs"
2 | import { defineConfig } from "rollup"
3 | import json from "@rollup/plugin-json"
4 | import { nodeResolve } from "@rollup/plugin-node-resolve"
5 | import { rmSync } from "fs"
6 | import typescript from "rollup-plugin-typescript2"
7 |
8 | export default defineConfig([
9 | {
10 | input: "./src/index.ts",
11 | output: {
12 | file: "dist/index.js",
13 | format: "cjs",
14 | },
15 | plugins: [
16 | {
17 | name: "del",
18 | transform (code, id) {
19 | if (id.endsWith(".cts") || id.endsWith(".mts")) return ""
20 | },
21 | buildStart () {
22 | rmSync("./dist", { recursive: true, force: true })
23 | },
24 | closeBundle () {
25 | rmSync("./dist/packages", { recursive: true, force: true })
26 | }
27 | },
28 | json(),
29 | commonjs(),
30 | nodeResolve(),
31 | typescript({
32 | tsconfigOverride: {
33 | include: ["packages/**/src"]
34 | }
35 | }),
36 | ],
37 | external: [
38 | "@swc/core",
39 | "@macro-plugin/core",
40 | "@macro-plugin/shared"
41 | ]
42 | }
43 | ])
44 |
--------------------------------------------------------------------------------
/packages/core/tests/__snapshots__/expr.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`create a template macro 1`] = `
4 | "let person = "Bob";
5 | let age = 12;
6 | const des = "That Bob is 12";
7 | "
8 | `;
9 |
10 | exports[`create a template macro 2`] = `
11 | "declare global {
12 | const real: (strings: TemplateStringsArray, ...expressions: unknown[]) => string;
13 | }
14 | export {}
15 | "
16 | `;
17 |
18 | exports[`create a type macro with createExprMacro 1`] = `
19 | "const emit = defineEmits([
20 | "change",
21 | "update"
22 | ]);
23 | "
24 | `;
25 |
26 | exports[`create a type macro with createExprMacro 2`] = `
27 | "declare global {
28 | const defineEmits: (...args: T[]) => T;
29 | }
30 | export {}
31 | "
32 | `;
33 |
34 | exports[`create a type macro with createTypeMacro 1`] = `
35 | "const emit = defineEmits([
36 | "change",
37 | "update"
38 | ]);
39 | "
40 | `;
41 |
42 | exports[`create a type macro with createTypeMacro 2`] = `
43 | "declare global {
44 | const defineEmits: () => T;
45 | }
46 | export {}
47 | "
48 | `;
49 |
50 | exports[`create complex expr macro 1`] = `
51 | "declare global {
52 | const $add: (a: number, b: number) => number;
53 | }
54 | export {}
55 | "
56 | `;
57 |
--------------------------------------------------------------------------------
/packages/core/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@macro-plugin/core",
3 | "version": "1.2.0",
4 | "description": "Macro system for JavaScript and TypeScript.",
5 | "main": "dist/index.js",
6 | "module": "dist/index.mjs",
7 | "types": "./dist/index.d.ts",
8 | "bin": {
9 | "macros": "dist/cli.js"
10 | },
11 | "files": [
12 | "dist",
13 | "CHANGELOG.md"
14 | ],
15 | "keywords": [
16 | "macro",
17 | "macros",
18 | "cli",
19 | "macro-plugin",
20 | "macro-system"
21 | ],
22 | "scripts": {
23 | "build": "rollup -c ../../rollup.config.mjs"
24 | },
25 | "dependencies": {
26 | "@swc/core": "^1.3.55"
27 | },
28 | "homepage": "https://github.com/macro-plugin/macros/tree/main/packages/core",
29 | "repository": {
30 | "type": "git",
31 | "url": "https://github.com/macro-plugin/macros.git"
32 | },
33 | "sideEffects": false,
34 | "exports": {
35 | "./package.json": "./package.json",
36 | ".": {
37 | "import": "./dist/index.mjs",
38 | "require": "./dist/index.js",
39 | "types": "./dist/index.d.ts"
40 | },
41 | "./cli": {
42 | "require": "./dist/cli.js"
43 | },
44 | "./register": {
45 | "require": "./dist/register.js"
46 | }
47 | },
48 | "author": "Raven Satir",
49 | "license": "MIT"
50 | }
51 |
--------------------------------------------------------------------------------
/packages/solid/tests/signal.test.ts:
--------------------------------------------------------------------------------
1 | import { signal } from "@macro-plugin/solid"
2 | import { transform } from "@macro-plugin/core"
3 |
4 | test("solid signal macro", () => {
5 | const code = `
6 | signal: {
7 | var count = 0
8 | }
9 |
10 | count += 2
11 | count = 5
12 | count *= 10
13 | count **= 2
14 | count++
15 | count--
16 | ++count
17 | --count
18 | `
19 |
20 | expect(transform(code, { macros: [signal] }).code).toMatchSnapshot()
21 | })
22 |
23 | test("overwrite signal inside function", () => {
24 | const code = `
25 | signal: {
26 | var count = 0
27 | var b = 2
28 | }
29 |
30 | count = 3
31 |
32 | function add(count = 0) {
33 | count += 1
34 | }
35 |
36 | count = 4
37 |
38 | const plus = (b) => {
39 | b = 5
40 | count += 3
41 |
42 | var count = 4
43 | count += 5
44 | }
45 |
46 | try {
47 | console.log(123)
48 | } catch (b) {
49 | b += 2
50 | }
51 |
52 | b += 2
53 | count += 2
54 |
55 | var b = 4
56 | b += 3
57 |
58 | function component() {
59 | signal: {
60 | var c = 3
61 | }
62 |
63 | c += 2
64 | }
65 | `
66 |
67 | expect(transform(code, { macros: [signal] }).code).toMatchSnapshot()
68 | })
69 |
--------------------------------------------------------------------------------
/packages/factory/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@macro-plugin/factory",
3 | "version": "1.2.1",
4 | "description": "Macro factories for creating AST.",
5 | "main": "dist/index.js",
6 | "module": "dist/index.mjs",
7 | "types": "dist/index.d.ts",
8 | "files": [
9 | "dist",
10 | "CHANGELOG.md"
11 | ],
12 | "keywords": [
13 | "factory",
14 | "macro",
15 | "macros",
16 | "macro-plugin"
17 | ],
18 | "scripts": {
19 | "build": "rollup -c ./rollup.config.mjs"
20 | },
21 | "dependencies": {
22 | "@macro-plugin/core": "1.2.0"
23 | },
24 | "homepage": "https://github.com/macro-plugin/macros/tree/main/packages/factory",
25 | "repository": {
26 | "type": "git",
27 | "url": "https://github.com/macro-plugin/macros.git"
28 | },
29 | "exports": {
30 | "./package.json": "./package.json",
31 | ".": {
32 | "import": "./dist/index.mjs",
33 | "require": "./dist/index.js",
34 | "types": "./dist/index.d.ts"
35 | },
36 | "./runtime": {
37 | "import": "./dist/runtime.mjs",
38 | "require": "./dist/runtime.js",
39 | "types": "./dist/runtime.d.ts"
40 | },
41 | "./macros": {
42 | "import": "./dist/macros.mjs",
43 | "require": "./dist/macros.js",
44 | "types": "./dist/macros.d.ts"
45 | }
46 | },
47 | "author": "Raven Satir",
48 | "license": "MIT"
49 | }
50 |
--------------------------------------------------------------------------------
/examples/vite-project/src/typescript.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/register/rollup.config.mjs:
--------------------------------------------------------------------------------
1 | import commonjs from "@rollup/plugin-commonjs"
2 | import { defineConfig } from "rollup"
3 | import json from "@rollup/plugin-json"
4 | import { nodeResolve } from "@rollup/plugin-node-resolve"
5 | import { rmSync } from "fs"
6 | import terser from "@rollup/plugin-terser"
7 | import typescript from "rollup-plugin-typescript2"
8 |
9 | /** @type { import("rollup").Plugin[] } */
10 | const plugins = [
11 | {
12 | name: "del",
13 | transform (code, id) {
14 | if (id.endsWith(".cts") || id.endsWith(".mts")) return ""
15 | },
16 | buildStart () {
17 | rmSync("./dist", { recursive: true, force: true })
18 | },
19 | closeBundle () {
20 | rmSync("./dist/packages", { recursive: true, force: true })
21 | }
22 | },
23 | json(),
24 | commonjs(),
25 | nodeResolve(),
26 | typescript({
27 | tsconfigOverride: {
28 | include: ["packages/**/src"]
29 | }
30 | }),
31 | terser({
32 | module: true,
33 | compress: {
34 | ecma: 2015,
35 | pure_getters: true,
36 | }
37 | })
38 | ]
39 |
40 | const external = [
41 | "@swc/core",
42 | "@macro-plugin/core"
43 | ]
44 |
45 | // compile to core dist folder
46 | export default defineConfig([
47 | {
48 | input: "./src/index.ts",
49 | output: {
50 | file: "./dist/register.js",
51 | format: "cjs",
52 | },
53 | plugins,
54 | external,
55 | },
56 | ])
57 |
--------------------------------------------------------------------------------
/packages/factory/README.md:
--------------------------------------------------------------------------------
1 | # @macro-plugin/factory
2 |
3 | Macro factories for simplify the process of creating swc AST.
4 |
5 | ## Installation
6 |
7 | ```sh
8 | # if you use npm
9 | npm i -D @macro-plugin/factory
10 | # if you use pnpm
11 | pnpm i -D @macro-plugin/factory
12 | # if you use yarn
13 | yarn add -D @macro-plugin/factory
14 | ```
15 |
16 | ## Usage
17 |
18 | Given an exmaple.
19 |
20 | ```js
21 | import { createIdentifier } from "@macro-plugin/factory"
22 |
23 | createIdentifier("hello")
24 |
25 | // {
26 | // type: "Identifier",
27 | // value: "hello",
28 | // optional: false,
29 | // span: {
30 | // start: 0,
31 | // end: 0,
32 | // ctxt: 0
33 | // }
34 | // }
35 |
36 | ```
37 |
38 | Or with macros
39 |
40 | ```js
41 | import { $Identifier } from "@macro-plugin/factory"
42 |
43 | $Identifier("hello")
44 | ```
45 |
46 | ## Runtime vs Macros
47 |
48 | The results generated by macros and runtime are the same in theory, but macros performance may be better.
49 |
50 | For example, with runtime, if you use `createIdentifier` api, then the `function createIdentifier` will be bundled to your macro plugin.
51 |
52 | If you use `$Identifier`, macro-plugin will replace your call with raw object `{ type: "Identifier", ... }`. So it will perform better.
53 |
54 | ## Built-in factory
55 |
56 | ### Runtime
57 |
58 | See [runtime](./src/runtime.ts)
59 |
60 | ### Macros
61 |
62 | See [macros](./src/macros.ts)
63 |
--------------------------------------------------------------------------------
/packages/register/src/transformer.ts:
--------------------------------------------------------------------------------
1 | import { MacroOptions, createSwcPlugin, getSpanOffset, transform } from "@macro-plugin/core"
2 | import { ParserConfig, parseSync as swcParse, transformSync as swcTransform } from "@swc/core"
3 |
4 | import type { Options } from "@swc/core"
5 | import { buildTransformOptionsSync } from "@macro-plugin/shared"
6 |
7 | var CURRENT_CONFIG: [Options, MacroOptions, string | undefined]
8 |
9 | function getConfig () {
10 | if (!CURRENT_CONFIG) CURRENT_CONFIG = buildTransformOptionsSync({})
11 | return CURRENT_CONFIG
12 | }
13 |
14 | export function transformJS (src: string) {
15 | const macroOptions = getConfig()[1]
16 | return transform(src, macroOptions).code
17 | }
18 |
19 | export function transformTS (src: string, filename: string) {
20 | const [swcOptions, macroOptions] = getConfig()
21 | const macroPlugin = createSwcPlugin(macroOptions, src, getSpanOffset())
22 |
23 | const isJsx = /\.(js|ts)x$/.test(filename)
24 | const parser: ParserConfig = /\.tsx?$/.test(filename)
25 | ? {
26 | syntax: "typescript",
27 | tsx: isJsx,
28 | }
29 | : {
30 | syntax: "ecmascript",
31 | jsx: isJsx
32 | }
33 |
34 | swcOptions.filename = filename
35 | if (swcOptions.jsc) {
36 | swcOptions.jsc.parser = parser
37 | } else {
38 | swcOptions.jsc = {
39 | parser
40 | }
41 | }
42 |
43 | const program = swcParse(src, parser)
44 | return swcTransform(macroPlugin(program), swcOptions).code
45 | }
46 |
--------------------------------------------------------------------------------
/examples/vite-project/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | jobs:
9 | release:
10 | permissions:
11 | contents: write # to create release (changesets/action)
12 | pull-requests: write # to create pull request (changesets/action)
13 | name: Release
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Checkout Repo
17 | uses: actions/checkout@v3
18 | with:
19 | # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
20 | fetch-depth: 0
21 |
22 | - uses: pnpm/action-setup@v2
23 | with:
24 | version: 7
25 |
26 | - name: Setup Node.js
27 | uses: actions/setup-node@v3
28 | with:
29 | node-version: 16.x
30 | cache: pnpm
31 |
32 | - name: Install Dependencies
33 | run: pnpm install --no-frozen-lockfile
34 |
35 | - name: Run tests
36 | run: pnpm test
37 |
38 | - name: Build project
39 | run: pnpm build:force
40 |
41 | - name: Create Release and Publish to npm
42 | id: changesets
43 | uses: changesets/action@v1
44 | with:
45 | publish: pnpm release
46 | commit: "ci: version packages"
47 | title: "ci: version packages"
48 | createGithubReleases: true
49 | env:
50 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
52 |
--------------------------------------------------------------------------------
/scripts/release.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-console */
2 | const path = require("path")
3 | const { readdirSync, existsSync } = require("fs")
4 | const { exec, getExecOutput } = require("@actions/exec")
5 |
6 | const { version } = require("../packages/core/package.json")
7 | const tag = `v${version}`
8 | const releaseLine = `v${version.split(".")[0]}`
9 |
10 | process.chdir(path.join(__dirname, ".."));
11 |
12 | (async () => {
13 | const { exitCode, stderr } = await getExecOutput(
14 | "git",
15 | ["ls-remote", "--exit-code", "origin", "--tags", `refs/tags/${tag}`],
16 | {
17 | ignoreReturnCode: true,
18 | }
19 | )
20 | if (exitCode === 0) {
21 | console.log(
22 | `Action is not being published because version ${tag} is already published`
23 | )
24 | return
25 | }
26 | if (exitCode !== 2) {
27 | throw new Error(`git ls-remote exited with ${exitCode}:\n${stderr}`)
28 | }
29 |
30 | // publish to npm
31 | await exec("changeset", ["publish"])
32 |
33 | // push to github
34 | await exec("git", ["checkout", "--detach"])
35 |
36 | for (const pkg of readdirSync("packages")) {
37 | if (existsSync(path.resolve(`packages/${pkg}/dist`))) {
38 | await exec("git", ["add", "--force", `packages/${pkg}/dist`])
39 | }
40 | }
41 |
42 | await exec("git", ["commit", "-m", tag])
43 |
44 | await exec("changeset", ["tag"])
45 |
46 | await exec("git", [
47 | "push",
48 | "--force",
49 | "--follow-tags",
50 | "origin",
51 | `HEAD:refs/heads/${releaseLine}`,
52 | ])
53 | })()
54 |
--------------------------------------------------------------------------------
/packages/qwik/tests/qwik.test.ts:
--------------------------------------------------------------------------------
1 | import { computed, qwik, signal } from "../src"
2 |
3 | import { transform } from "@macro-plugin/core"
4 |
5 | test("qwik labeled macro", () => {
6 | const code = `
7 | function Cmp() {
8 | qwik: true
9 | }
10 | `
11 | expect(transform(code, { macros: [qwik] }).code).toMatchSnapshot()
12 | })
13 |
14 | test("qwik labeled macro with value false", () => {
15 | const code = `
16 | function Cmp() {
17 | qwik: false
18 | }
19 | `
20 | expect(transform(code, { macros: [qwik] }).code).toMatchSnapshot()
21 | })
22 |
23 | test("qwik labeled macro with wrong value", () => {
24 | const code = `
25 | function Cmp() {
26 | qwik: {}
27 | }
28 | `
29 | expect(() => transform(code, { macros: [qwik] }).code).toThrow()
30 | })
31 |
32 | test("qwik labeled macro in function expression", () => {
33 | const code = `
34 | const ABC = function() {
35 | qwik: true
36 | }
37 |
38 | export const Cmp = () => {
39 | qwik: true
40 | }
41 | `
42 | expect(transform(code, { macros: [qwik] }).code).toMatchSnapshot()
43 | })
44 |
45 | test("complex qwik app", () => {
46 | const code = `
47 | export function Cmp() {
48 | qwik: true
49 | signal: {
50 | var count = 1
51 | }
52 | computed: {
53 | var doubleCount = 2 * count
54 | }
55 | return (
56 |