@fastkit/plugboy-vanilla-extract-plugin 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-present, Ayumu Fujii (dadajam4) and Fastkit contributors
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.
@@ -0,0 +1,29 @@
1
+ import { Plugin } from '@fastkit/plugboy';
2
+ import { vanillaExtractPlugin } from '@vanilla-extract/esbuild-plugin';
3
+ import { Plugin as Plugin$1 } from 'vite';
4
+ import { vanillaExtractPlugin as vanillaExtractPlugin$1 } from '@vanilla-extract/vite-plugin';
5
+
6
+ type VanillaExtractPluginOptions = NonNullable<Parameters<typeof vanillaExtractPlugin>[0]>;
7
+ interface VanillaExtractEsbuildOptions extends NonNullable<VanillaExtractPluginOptions['esbuildOptions']> {
8
+ }
9
+ interface PluginOptions extends Pick<VanillaExtractPluginOptions, 'identifiers' | 'esbuildOptions'> {
10
+ }
11
+ declare const PLUGIN_NAME = "plugboy-vanilla-extract";
12
+ interface VanillaExtractPlugin extends Plugin {
13
+ name: typeof PLUGIN_NAME;
14
+ options: PluginOptions;
15
+ }
16
+
17
+ declare module '@fastkit/plugboy' {
18
+ interface WorkspaceMeta {
19
+ hasVanillaExtract: boolean;
20
+ }
21
+ }
22
+ declare function createVanillaExtractPlugin(options?: PluginOptions): Promise<VanillaExtractPlugin>;
23
+
24
+ type VanillaExtractVitePluginOptions = NonNullable<Parameters<typeof vanillaExtractPlugin$1>[0]>;
25
+ interface ViteVanillaExtractPluginOptions extends VanillaExtractVitePluginOptions {
26
+ }
27
+ declare function ViteVanillaExtractPlugin(options?: ViteVanillaExtractPluginOptions): Promise<Plugin$1>;
28
+
29
+ export { PLUGIN_NAME, PluginOptions, VanillaExtractEsbuildOptions, VanillaExtractPlugin, ViteVanillaExtractPlugin, ViteVanillaExtractPluginOptions, createVanillaExtractPlugin };
@@ -0,0 +1,77 @@
1
+ import { definePlugin, findFile, findProjectPlugin } from '@fastkit/plugboy';
2
+ import { vanillaExtractPlugin as vanillaExtractPlugin$1 } from '@vanilla-extract/esbuild-plugin';
3
+ import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
4
+
5
+ // src/types.ts
6
+ var PLUGIN_NAME = "plugboy-vanilla-extract";
7
+
8
+ // src/utils.ts
9
+ var EXTERNAL_DEFAULTS = ["node:*"];
10
+ function mergeExternal(...chunks) {
11
+ const result = [...EXTERNAL_DEFAULTS];
12
+ for (const chunk of chunks) {
13
+ chunk && result.push(...chunk);
14
+ }
15
+ return Array.from(new Set(result));
16
+ }
17
+
18
+ // src/esbuild.ts
19
+ function ESBuildVanillaExtract(options = {}) {
20
+ const { esbuildOptions = {} } = options;
21
+ return vanillaExtractPlugin$1({
22
+ ...options,
23
+ esbuildOptions: {
24
+ ...esbuildOptions,
25
+ external: mergeExternal(esbuildOptions.external)
26
+ }
27
+ });
28
+ }
29
+
30
+ // src/plugin.ts
31
+ async function createVanillaExtractPlugin(options = {}) {
32
+ return definePlugin({
33
+ name: PLUGIN_NAME,
34
+ options,
35
+ hooks: {
36
+ async setupWorkspace(ctx) {
37
+ const { external = [] } = ctx.config;
38
+ ctx.config.external = [...external, /@vanilla\-extract/];
39
+ ctx.meta.hasVanillaExtract = await !!findFile(
40
+ ctx.dirs.src.value,
41
+ /\.css\.ts$/
42
+ );
43
+ }
44
+ },
45
+ esbuildPlugins: [
46
+ (workspace) => {
47
+ if (!workspace.meta.hasVanillaExtract)
48
+ return;
49
+ return ESBuildVanillaExtract(options);
50
+ }
51
+ ]
52
+ });
53
+ }
54
+ async function ViteVanillaExtractPlugin(options = {}) {
55
+ const plugin = await findProjectPlugin(PLUGIN_NAME);
56
+ const {
57
+ identifiers: baseIdentifiers,
58
+ esbuildOptions: baseEsbuildOptions = {}
59
+ } = plugin?.options || {};
60
+ const { esbuildOptions = {} } = options;
61
+ return vanillaExtractPlugin({
62
+ identifiers: baseIdentifiers,
63
+ ...options,
64
+ esbuildOptions: {
65
+ ...baseEsbuildOptions,
66
+ ...esbuildOptions,
67
+ external: mergeExternal(
68
+ baseEsbuildOptions.external,
69
+ esbuildOptions.external
70
+ )
71
+ }
72
+ });
73
+ }
74
+
75
+ export { PLUGIN_NAME, ViteVanillaExtractPlugin, createVanillaExtractPlugin };
76
+ //# sourceMappingURL=out.js.map
77
+ //# sourceMappingURL=plugboy-vanilla-extract-plugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts","../src/plugin.ts","../src/esbuild.ts","../src/utils.ts","../src/vite.ts"],"names":["vanillaExtractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,IAAM,cAAc;;;ACf3B,SAAS,cAAc,gBAAgB;;;ACCvC,SAAS,4BAA4B;;;ACDrC,IAAM,oBAAoB,CAAC,QAAQ;AAE5B,SAAS,iBAAiB,QAA4C;AA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,GAAG;AAAA,IACH,gBAAgB;AAAA,MACd,GAAG;AAAA,MACH,GAAG;AAAA,MACH,UAAU;AAAA,QACR,mBAAmB;AAAA,QACnB,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF,CAAC;AACH","sourcesContent":["import { Plugin } from '@fastkit/plugboy';\nimport type { vanillaExtractPlugin as esbuildPlugin } from '@vanilla-extract/esbuild-plugin';\n\ntype VanillaExtractPluginOptions = NonNullable<\n Parameters<typeof esbuildPlugin>[0]\n>;\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface VanillaExtractEsbuildOptions\n extends NonNullable<VanillaExtractPluginOptions['esbuildOptions']> {}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface PluginOptions\n extends Pick<VanillaExtractPluginOptions, 'identifiers' | 'esbuildOptions'> {}\n\nexport const PLUGIN_NAME = 'plugboy-vanilla-extract';\n\nexport interface VanillaExtractPlugin extends Plugin {\n name: typeof PLUGIN_NAME;\n options: PluginOptions;\n}\n","import { definePlugin, findFile } from '@fastkit/plugboy';\nimport { ESBuildVanillaExtract } from './esbuild';\nimport { VanillaExtractPlugin, PluginOptions, PLUGIN_NAME } from './types';\n\ndeclare module '@fastkit/plugboy' {\n export interface WorkspaceMeta {\n hasVanillaExtract: boolean;\n }\n}\n\nexport async function createVanillaExtractPlugin(options: PluginOptions = {}) {\n return definePlugin<VanillaExtractPlugin>({\n name: PLUGIN_NAME,\n options,\n hooks: {\n async setupWorkspace(ctx) {\n const { external = [] } = ctx.config;\n\n ctx.config.external = [...external, /@vanilla\\-extract/];\n\n ctx.meta.hasVanillaExtract = await !!findFile(\n ctx.dirs.src.value,\n /\\.css\\.ts$/,\n );\n },\n },\n esbuildPlugins: [\n (workspace) => {\n if (!workspace.meta.hasVanillaExtract) return;\n return ESBuildVanillaExtract(options);\n },\n ],\n });\n}\n","import { ESBuildPlugin } from '@fastkit/plugboy';\nimport { vanillaExtractPlugin } from '@vanilla-extract/esbuild-plugin';\nimport { PluginOptions } from './types';\nimport { mergeExternal } from './utils';\n\nexport function ESBuildVanillaExtract(\n options: PluginOptions = {},\n): ESBuildPlugin {\n const { esbuildOptions = {} } = options;\n return vanillaExtractPlugin({\n ...options,\n esbuildOptions: {\n ...esbuildOptions,\n external: mergeExternal(esbuildOptions.external),\n },\n }) as any;\n}\n","const EXTERNAL_DEFAULTS = ['node:*'];\n\nexport function mergeExternal(...chunks: (string[] | undefined)[]): string[] {\n const result: string[] = [...EXTERNAL_DEFAULTS];\n for (const chunk of chunks) {\n chunk && result.push(...chunk);\n }\n return Array.from(new Set(result));\n}\n","import { PLUGIN_NAME, VanillaExtractPlugin } from './types';\nimport { findProjectPlugin } from '@fastkit/plugboy';\nimport { Plugin as VitePlugin } from 'vite';\nimport { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';\nimport { mergeExternal } from './utils';\n\ntype VanillaExtractVitePluginOptions = NonNullable<\n Parameters<typeof vanillaExtractPlugin>[0]\n>;\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface ViteVanillaExtractPluginOptions\n extends VanillaExtractVitePluginOptions {}\n\nexport async function ViteVanillaExtractPlugin(\n options: ViteVanillaExtractPluginOptions = {},\n): Promise<VitePlugin> {\n const plugin = await findProjectPlugin<VanillaExtractPlugin>(PLUGIN_NAME);\n const {\n identifiers: baseIdentifiers,\n esbuildOptions: baseEsbuildOptions = {},\n } = plugin?.options || {};\n\n const { esbuildOptions = {} } = options;\n\n return vanillaExtractPlugin({\n identifiers: baseIdentifiers,\n ...options,\n esbuildOptions: {\n ...baseEsbuildOptions,\n ...esbuildOptions,\n external: mergeExternal(\n baseEsbuildOptions.external,\n esbuildOptions.external,\n ),\n },\n });\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@fastkit/plugboy-vanilla-extract-plugin",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "keywords": [],
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/dadajam4/fastkit.git"
9
+ },
10
+ "license": "MIT",
11
+ "author": "dadajam4",
12
+ "type": "module",
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "types": "./dist/plugboy-vanilla-extract-plugin.d.ts",
17
+ "import": {
18
+ "default": "./dist/plugboy-vanilla-extract-plugin.mjs"
19
+ }
20
+ },
21
+ "./*": "./dist/*"
22
+ },
23
+ "main": "./dist/plugboy-vanilla-extract-plugin.mjs",
24
+ "types": "./dist/plugboy-vanilla-extract-plugin.d.ts",
25
+ "typesVersions": {
26
+ "*": {
27
+ ".": [
28
+ "./dist/plugboy-vanilla-extract-plugin.d.ts"
29
+ ]
30
+ }
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "dependencies": {
36
+ "@vanilla-extract/css": "^1.11.0",
37
+ "@vanilla-extract/esbuild-plugin": "^2.2.2",
38
+ "@vanilla-extract/vite-plugin": "^3.8.0"
39
+ },
40
+ "devDependencies": {
41
+ "vite": "^4.1.1",
42
+ "@fastkit/plugboy": "0.0.1"
43
+ },
44
+ "peerDependencies": {
45
+ "vite": "^4.1.1",
46
+ "@fastkit/plugboy": "0.0.1"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@vanilla-extract/vite-plugin": {
50
+ "optional": true
51
+ },
52
+ "vite": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "scripts": {
57
+ "build": "plugboy build",
58
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
59
+ "eslint": "eslint . --ext ts,tsx,js,vue,html,yaml",
60
+ "eslint:fix": "eslint . --ext ts,tsx,js,vue,html,yaml --fix",
61
+ "format": "pnpm run eslint:fix",
62
+ "lint": "pnpm run eslint",
63
+ "test": "vitest run",
64
+ "typecheck": "tsc --noEmit"
65
+ }
66
+ }