@jk2908/cxx 0.1.8 → 0.1.9

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.
@@ -0,0 +1,9 @@
1
+ declare module 'react' {
2
+ interface StyleHTMLAttributes<T> extends React.HTMLAttributes<T> {
3
+ href?: string;
4
+ precedence?: 'low' | 'medium' | 'high';
5
+ }
6
+ }
7
+ declare const cxx: (_: TemplateStringsArray) => readonly ["", Record<string, string>, ""];
8
+
9
+ export { cxx };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ const cxx = (_)=>[
2
+ '',
3
+ {},
4
+ ''
5
+ ];
6
+
7
+ export { cxx };
@@ -0,0 +1,60 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var lightningcss = require('lightningcss');
4
+
5
+ // cyrb53 (c) 2018 bryc (github.com/bryc)
6
+ // https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
7
+ function cyrb53(str, seed = 0) {
8
+ let h1 = 0xdeadbeef ^ seed;
9
+ let h2 = 0x41c6ce57 ^ seed;
10
+ for(let i = 0, ch; i < str.length; i++){
11
+ ch = str.charCodeAt(i);
12
+ h1 = Math.imul(h1 ^ ch, 2654435761);
13
+ h2 = Math.imul(h2 ^ ch, 1597334677);
14
+ }
15
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
16
+ h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
17
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
18
+ h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
19
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
20
+ }
21
+
22
+ const varMatch = /(?:const|var|let)\s*\[(\w+|)\s*,?\s*(\w+|)\s*,?\s*(\w+|)\s*\]\s*=\s*cxx\s*`([\s\S]*?)`/gm;
23
+ const DEFAULT_CONFIG = {
24
+ lightningcss: {
25
+ minify: true,
26
+ cssModules: true
27
+ }
28
+ };
29
+ function inject(source, id, config = {}) {
30
+ try {
31
+ const tmpl = source.replace(varMatch, (_, ...args)=>{
32
+ const [varOne, varTwo, varThree, css] = args;
33
+ const { code, exports } = lightningcss.transform({
34
+ ...DEFAULT_CONFIG.lightningcss,
35
+ ...config.lightningcss,
36
+ filename: id,
37
+ code: new TextEncoder().encode(css)
38
+ });
39
+ const href = cyrb53([
40
+ ...Object.keys(exports ?? {}),
41
+ id
42
+ ].join(''));
43
+ const classes = exports ? Object.fromEntries(Object.entries(exports).map(([key, value])=>[
44
+ key,
45
+ value.name
46
+ ])) : {};
47
+ return [
48
+ varOne && `const ${varOne} = \`${code}\``,
49
+ varTwo && `const ${varTwo} = ${JSON.stringify(classes)}`,
50
+ varThree && `const ${varThree} = \`${href}\``
51
+ ].filter(Boolean).join('\n');
52
+ });
53
+ return tmpl;
54
+ } catch (err) {
55
+ console.error('cxx error :(', err);
56
+ return source;
57
+ }
58
+ }
59
+
60
+ exports.inject = inject;
@@ -0,0 +1,8 @@
1
+ import { CustomAtRules, TransformOptions } from 'lightningcss';
2
+
3
+ type Config<C extends CustomAtRules = CustomAtRules> = {
4
+ lightningcss?: Partial<TransformOptions<C>>;
5
+ };
6
+ declare function inject<C extends CustomAtRules = CustomAtRules>(source: string, id: string, config?: Config<C>): string;
7
+
8
+ export { type Config, inject };
@@ -0,0 +1,58 @@
1
+ import { transform } from 'lightningcss';
2
+
3
+ // cyrb53 (c) 2018 bryc (github.com/bryc)
4
+ // https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
5
+ function cyrb53(str, seed = 0) {
6
+ let h1 = 0xdeadbeef ^ seed;
7
+ let h2 = 0x41c6ce57 ^ seed;
8
+ for(let i = 0, ch; i < str.length; i++){
9
+ ch = str.charCodeAt(i);
10
+ h1 = Math.imul(h1 ^ ch, 2654435761);
11
+ h2 = Math.imul(h2 ^ ch, 1597334677);
12
+ }
13
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
14
+ h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
15
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
16
+ h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
17
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
18
+ }
19
+
20
+ const varMatch = /(?:const|var|let)\s*\[(\w+|)\s*,?\s*(\w+|)\s*,?\s*(\w+|)\s*\]\s*=\s*cxx\s*`([\s\S]*?)`/gm;
21
+ const DEFAULT_CONFIG = {
22
+ lightningcss: {
23
+ minify: true,
24
+ cssModules: true
25
+ }
26
+ };
27
+ function inject(source, id, config = {}) {
28
+ try {
29
+ const tmpl = source.replace(varMatch, (_, ...args)=>{
30
+ const [varOne, varTwo, varThree, css] = args;
31
+ const { code, exports } = transform({
32
+ ...DEFAULT_CONFIG.lightningcss,
33
+ ...config.lightningcss,
34
+ filename: id,
35
+ code: new TextEncoder().encode(css)
36
+ });
37
+ const href = cyrb53([
38
+ ...Object.keys(exports ?? {}),
39
+ id
40
+ ].join(''));
41
+ const classes = exports ? Object.fromEntries(Object.entries(exports).map(([key, value])=>[
42
+ key,
43
+ value.name
44
+ ])) : {};
45
+ return [
46
+ varOne && `const ${varOne} = \`${code}\``,
47
+ varTwo && `const ${varTwo} = ${JSON.stringify(classes)}`,
48
+ varThree && `const ${varThree} = \`${href}\``
49
+ ].filter(Boolean).join('\n');
50
+ });
51
+ return tmpl;
52
+ } catch (err) {
53
+ console.error('cxx error :(', err);
54
+ return source;
55
+ }
56
+ }
57
+
58
+ export { inject };
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var index_cjs = require('../inject/index.cjs');
4
+
5
+ function loader(source) {
6
+ return index_cjs.inject(source, this.resourcePath, this.getOptions());
7
+ }
8
+
9
+ exports.default = loader;
@@ -0,0 +1,7 @@
1
+ import { inject } from '../inject/index.js';
2
+
3
+ function loader(source) {
4
+ return inject(source, this.resourcePath, this.getOptions())
5
+ }
6
+
7
+ export { loader as default };
@@ -0,0 +1,7 @@
1
+ import { inject } from '../inject/index.js';
2
+
3
+ function loader(source) {
4
+ return inject(source, this.resourcePath, this.getOptions());
5
+ }
6
+
7
+ export { loader as default };
@@ -0,0 +1,328 @@
1
+ import * as next_dist_shared_lib_image_config from 'next/dist/shared/lib/image-config';
2
+ import * as next_dist_lib_load_custom_routes from 'next/dist/lib/load-custom-routes';
3
+ import * as next_dist_server_config_shared from 'next/dist/server/config-shared';
4
+ import { WebpackConfigContext } from 'next/dist/server/config-shared';
5
+ import * as next_dist_cli_next_test from 'next/dist/cli/next-test';
6
+ import * as next from 'next';
7
+ import { NextConfig } from 'next';
8
+ import * as next_dist_server_lib_experimental_ppr from 'next/dist/server/lib/experimental/ppr';
9
+ import * as next_dist_shared_lib_utils from 'next/dist/shared/lib/utils';
10
+ import * as next_dist_build_webpack_plugins_subresource_integrity_plugin from 'next/dist/build/webpack/plugins/subresource-integrity-plugin';
11
+ import * as next_dist_compiled_webpack_webpack from 'next/dist/compiled/webpack/webpack';
12
+ import * as next_dist_server_lib_revalidate from 'next/dist/server/lib/revalidate';
13
+ import { Configuration } from 'webpack';
14
+ import { Config } from '../inject/index.js';
15
+
16
+ declare function withCxx(nextConfig?: NextConfig, config?: Config): {
17
+ experimental: {
18
+ turbo: any;
19
+ flyingShuttle?: boolean;
20
+ prerenderEarlyExit?: boolean;
21
+ linkNoTouchStart?: boolean;
22
+ caseSensitiveRoutes?: boolean;
23
+ appDocumentPreloading?: boolean;
24
+ preloadEntriesOnStart?: boolean;
25
+ strictNextHead?: boolean;
26
+ clientRouterFilter?: boolean;
27
+ clientRouterFilterRedirects?: boolean;
28
+ staleTimes?: {
29
+ dynamic?: number;
30
+ static?: number;
31
+ };
32
+ clientRouterFilterAllowedRate?: number;
33
+ externalMiddlewareRewritesResolve?: boolean;
34
+ extensionAlias?: Record<string, any>;
35
+ allowedRevalidateHeaderKeys?: string[];
36
+ fetchCacheKeyPrefix?: string;
37
+ optimisticClientCache?: boolean;
38
+ swrDelta?: next_dist_server_lib_revalidate.SwrDelta;
39
+ middlewarePrefetch?: "strict" | "flexible";
40
+ manualClientBasePath?: boolean;
41
+ cssChunking?: "strict" | "loose";
42
+ disablePostcssPresetEnv?: boolean;
43
+ cpus?: number;
44
+ memoryBasedWorkersCount?: boolean;
45
+ proxyTimeout?: number;
46
+ isrFlushToDisk?: boolean;
47
+ workerThreads?: boolean;
48
+ optimizeCss?: boolean | Record<string, unknown>;
49
+ nextScriptWorkers?: boolean;
50
+ scrollRestoration?: boolean;
51
+ externalDir?: boolean;
52
+ amp?: {
53
+ optimizer?: any;
54
+ validator?: string;
55
+ skipValidation?: boolean;
56
+ };
57
+ disableOptimizedLoading?: boolean;
58
+ gzipSize?: boolean;
59
+ craCompat?: boolean;
60
+ esmExternals?: boolean | "loose";
61
+ fullySpecified?: boolean;
62
+ urlImports?: NonNullable<next_dist_compiled_webpack_webpack.webpack.Configuration["experiments"]>["buildHttp"];
63
+ outputFileTracingRoot?: string;
64
+ outputFileTracingExcludes?: Record<string, string[]>;
65
+ outputFileTracingIgnores?: string[];
66
+ outputFileTracingIncludes?: Record<string, string[]>;
67
+ swcTraceProfiling?: boolean;
68
+ forceSwcTransforms?: boolean;
69
+ swcPlugins?: Array<[string, Record<string, unknown>]>;
70
+ largePageDataBytes?: number;
71
+ fallbackNodePolyfills?: false;
72
+ sri?: {
73
+ algorithm?: next_dist_build_webpack_plugins_subresource_integrity_plugin.SubresourceIntegrityAlgorithm;
74
+ };
75
+ adjustFontFallbacks?: boolean;
76
+ adjustFontFallbacksWithSizeAdjust?: boolean;
77
+ webVitalsAttribution?: Array<typeof next_dist_shared_lib_utils.WEB_VITALS[number]>;
78
+ optimizePackageImports?: string[];
79
+ optimizeServerReact?: boolean;
80
+ turbotrace?: {
81
+ logLevel?: "bug" | "fatal" | "error" | "warning" | "hint" | "note" | "suggestions" | "info";
82
+ logDetail?: boolean;
83
+ logAll?: boolean;
84
+ contextDirectory?: string;
85
+ processCwd?: string;
86
+ memoryLimit?: number;
87
+ };
88
+ mdxRs?: boolean | {
89
+ development?: boolean;
90
+ jsx?: boolean;
91
+ jsxRuntime?: string;
92
+ jsxImportSource?: string;
93
+ providerImportSource?: string;
94
+ mdxType?: "gfm" | "commonmark";
95
+ };
96
+ typedRoutes?: boolean;
97
+ parallelServerCompiles?: boolean;
98
+ parallelServerBuildTraces?: boolean;
99
+ webpackBuildWorker?: boolean;
100
+ webpackMemoryOptimizations?: boolean;
101
+ instrumentationHook?: boolean;
102
+ clientTraceMetadata?: string[];
103
+ ppr?: next_dist_server_lib_experimental_ppr.ExperimentalPPRConfig;
104
+ taint?: boolean;
105
+ serverActions?: {
106
+ bodySizeLimit?: next.SizeLimit;
107
+ allowedOrigins?: string[];
108
+ };
109
+ serverMinification?: boolean;
110
+ serverSourceMaps?: boolean;
111
+ staticWorkerRequestDeduping?: boolean;
112
+ useWasmBinary?: boolean;
113
+ useLightningcss?: boolean;
114
+ useEarlyImport?: boolean;
115
+ testProxy?: boolean;
116
+ defaultTestRunner?: next_dist_cli_next_test.SupportedTestRunners;
117
+ allowDevelopmentBuild?: true;
118
+ bundlePagesExternals?: boolean;
119
+ serverComponentsExternalPackages?: string[];
120
+ reactCompiler?: boolean | next_dist_server_config_shared.ReactCompilerOptions;
121
+ after?: boolean;
122
+ };
123
+ webpack(conf: Configuration, options: WebpackConfigContext): any;
124
+ exportPathMap?: (defaultMap: next_dist_server_config_shared.ExportPathMap, ctx: {
125
+ dev: boolean;
126
+ dir: string;
127
+ outDir: string | null;
128
+ distDir: string;
129
+ buildId: string;
130
+ }) => Promise<next_dist_server_config_shared.ExportPathMap> | next_dist_server_config_shared.ExportPathMap;
131
+ i18n?: next_dist_server_config_shared.I18NConfig | null;
132
+ eslint?: next_dist_server_config_shared.ESLintConfig;
133
+ typescript?: next_dist_server_config_shared.TypeScriptConfig;
134
+ headers?: () => Promise<next_dist_lib_load_custom_routes.Header[]>;
135
+ rewrites?: () => Promise<next_dist_lib_load_custom_routes.Rewrite[] | {
136
+ beforeFiles: next_dist_lib_load_custom_routes.Rewrite[];
137
+ afterFiles: next_dist_lib_load_custom_routes.Rewrite[];
138
+ fallback: next_dist_lib_load_custom_routes.Rewrite[];
139
+ }>;
140
+ redirects?: () => Promise<next_dist_lib_load_custom_routes.Redirect[]>;
141
+ excludeDefaultMomentLocales?: boolean;
142
+ trailingSlash?: boolean;
143
+ env?: Record<string, string | undefined>;
144
+ distDir?: string;
145
+ cleanDistDir?: boolean;
146
+ assetPrefix?: string;
147
+ cacheHandler?: string | undefined;
148
+ cacheMaxMemorySize?: number;
149
+ useFileSystemPublicRoutes?: boolean;
150
+ generateBuildId?: () => string | null | Promise<string | null>;
151
+ generateEtags?: boolean;
152
+ pageExtensions?: string[];
153
+ compress?: boolean;
154
+ poweredByHeader?: boolean;
155
+ images?: next_dist_shared_lib_image_config.ImageConfig;
156
+ devIndicators?: {
157
+ buildActivity?: boolean;
158
+ buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
159
+ };
160
+ onDemandEntries?: {
161
+ maxInactiveAge?: number;
162
+ pagesBufferLength?: number;
163
+ };
164
+ amp?: {
165
+ canonicalBase?: string;
166
+ };
167
+ deploymentId?: string;
168
+ basePath?: string;
169
+ sassOptions?: {
170
+ [key: string]: any;
171
+ };
172
+ productionBrowserSourceMaps?: boolean;
173
+ optimizeFonts?: boolean;
174
+ reactProductionProfiling?: boolean;
175
+ reactStrictMode?: boolean | null;
176
+ publicRuntimeConfig?: {
177
+ [key: string]: any;
178
+ };
179
+ serverRuntimeConfig?: {
180
+ [key: string]: any;
181
+ };
182
+ httpAgentOptions?: {
183
+ keepAlive?: boolean;
184
+ };
185
+ staticPageGenerationTimeout?: number;
186
+ crossOrigin?: "anonymous" | "use-credentials";
187
+ compiler?: {
188
+ reactRemoveProperties?: boolean | {
189
+ properties?: string[];
190
+ };
191
+ relay?: {
192
+ src: string;
193
+ artifactDirectory?: string;
194
+ language?: "typescript" | "javascript" | "flow";
195
+ eagerEsModules?: boolean;
196
+ };
197
+ removeConsole?: boolean | {
198
+ exclude?: string[];
199
+ };
200
+ styledComponents?: boolean | next_dist_server_config_shared.StyledComponentsConfig;
201
+ emotion?: boolean | next_dist_server_config_shared.EmotionConfig;
202
+ styledJsx?: boolean | {
203
+ useLightningcss?: boolean;
204
+ };
205
+ };
206
+ output?: "standalone" | "export";
207
+ transpilePackages?: string[];
208
+ skipMiddlewareUrlNormalize?: boolean;
209
+ skipTrailingSlashRedirect?: boolean;
210
+ modularizeImports?: Record<string, {
211
+ transform: string | Record<string, string>;
212
+ preventFullImport?: boolean;
213
+ skipDefaultConversion?: boolean;
214
+ }>;
215
+ logging?: {
216
+ fetches?: {
217
+ fullUrl?: boolean;
218
+ };
219
+ };
220
+ swrDelta?: next_dist_server_lib_revalidate.SwrDelta;
221
+ bundlePagesRouterDependencies?: boolean;
222
+ serverExternalPackages?: string[];
223
+ } | {
224
+ turbo: any;
225
+ webpack(conf: Configuration, options: WebpackConfigContext): any;
226
+ exportPathMap?: (defaultMap: next_dist_server_config_shared.ExportPathMap, ctx: {
227
+ dev: boolean;
228
+ dir: string;
229
+ outDir: string | null;
230
+ distDir: string;
231
+ buildId: string;
232
+ }) => Promise<next_dist_server_config_shared.ExportPathMap> | next_dist_server_config_shared.ExportPathMap;
233
+ i18n?: next_dist_server_config_shared.I18NConfig | null;
234
+ eslint?: next_dist_server_config_shared.ESLintConfig;
235
+ typescript?: next_dist_server_config_shared.TypeScriptConfig;
236
+ headers?: () => Promise<next_dist_lib_load_custom_routes.Header[]>;
237
+ rewrites?: () => Promise<next_dist_lib_load_custom_routes.Rewrite[] | {
238
+ beforeFiles: next_dist_lib_load_custom_routes.Rewrite[];
239
+ afterFiles: next_dist_lib_load_custom_routes.Rewrite[];
240
+ fallback: next_dist_lib_load_custom_routes.Rewrite[];
241
+ }>;
242
+ redirects?: () => Promise<next_dist_lib_load_custom_routes.Redirect[]>;
243
+ excludeDefaultMomentLocales?: boolean;
244
+ trailingSlash?: boolean;
245
+ env?: Record<string, string | undefined>;
246
+ distDir?: string;
247
+ cleanDistDir?: boolean;
248
+ assetPrefix?: string;
249
+ cacheHandler?: string | undefined;
250
+ cacheMaxMemorySize?: number;
251
+ useFileSystemPublicRoutes?: boolean;
252
+ generateBuildId?: () => string | null | Promise<string | null>;
253
+ generateEtags?: boolean;
254
+ pageExtensions?: string[];
255
+ compress?: boolean;
256
+ poweredByHeader?: boolean;
257
+ images?: next_dist_shared_lib_image_config.ImageConfig;
258
+ devIndicators?: {
259
+ buildActivity?: boolean;
260
+ buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
261
+ };
262
+ onDemandEntries?: {
263
+ maxInactiveAge?: number;
264
+ pagesBufferLength?: number;
265
+ };
266
+ amp?: {
267
+ canonicalBase?: string;
268
+ };
269
+ deploymentId?: string;
270
+ basePath?: string;
271
+ sassOptions?: {
272
+ [key: string]: any;
273
+ };
274
+ productionBrowserSourceMaps?: boolean;
275
+ optimizeFonts?: boolean;
276
+ reactProductionProfiling?: boolean;
277
+ reactStrictMode?: boolean | null;
278
+ publicRuntimeConfig?: {
279
+ [key: string]: any;
280
+ };
281
+ serverRuntimeConfig?: {
282
+ [key: string]: any;
283
+ };
284
+ httpAgentOptions?: {
285
+ keepAlive?: boolean;
286
+ };
287
+ staticPageGenerationTimeout?: number;
288
+ crossOrigin?: "anonymous" | "use-credentials";
289
+ compiler?: {
290
+ reactRemoveProperties?: boolean | {
291
+ properties?: string[];
292
+ };
293
+ relay?: {
294
+ src: string;
295
+ artifactDirectory?: string;
296
+ language?: "typescript" | "javascript" | "flow";
297
+ eagerEsModules?: boolean;
298
+ };
299
+ removeConsole?: boolean | {
300
+ exclude?: string[];
301
+ };
302
+ styledComponents?: boolean | next_dist_server_config_shared.StyledComponentsConfig;
303
+ emotion?: boolean | next_dist_server_config_shared.EmotionConfig;
304
+ styledJsx?: boolean | {
305
+ useLightningcss?: boolean;
306
+ };
307
+ };
308
+ output?: "standalone" | "export";
309
+ transpilePackages?: string[];
310
+ skipMiddlewareUrlNormalize?: boolean;
311
+ skipTrailingSlashRedirect?: boolean;
312
+ modularizeImports?: Record<string, {
313
+ transform: string | Record<string, string>;
314
+ preventFullImport?: boolean;
315
+ skipDefaultConversion?: boolean;
316
+ }>;
317
+ logging?: {
318
+ fetches?: {
319
+ fullUrl?: boolean;
320
+ };
321
+ };
322
+ swrDelta?: next_dist_server_lib_revalidate.SwrDelta;
323
+ experimental?: next_dist_server_config_shared.ExperimentalConfig;
324
+ bundlePagesRouterDependencies?: boolean;
325
+ serverExternalPackages?: string[];
326
+ };
327
+
328
+ export { withCxx };
@@ -0,0 +1,55 @@
1
+ import __node_cjsPath from 'node:path';
2
+ import __node_cjsUrl from 'node:url';
3
+ import __node_cjsModule from 'node:module';
4
+
5
+ const __filename = __node_cjsUrl.fileURLToPath(import.meta.url);
6
+ const __dirname = __node_cjsPath.dirname(__filename);
7
+ const require = __node_cjsModule.createRequire(import.meta.url);
8
+
9
+ function withCxx(nextConfig = {}, config = {}) {
10
+ const pkg = require('next/package.json');
11
+ const IS_CANARY = pkg.version?.includes('canary') ?? false;
12
+ const IS_TURBO = process.env.TURBOPACK === '1';
13
+ const TURBO_GLOB = '*.{tsx,jsx,ts,js}';
14
+ const loader = __node_cjsPath.resolve(__dirname, `cxx-loader.${IS_TURBO ? 'cjs' : 'js'}`);
15
+ const turboConfig = {
16
+ ...nextConfig.turbo,
17
+ rules: {
18
+ ...nextConfig.turbo?.rules,
19
+ [TURBO_GLOB]: {
20
+ loaders: [
21
+ ...nextConfig.turbo?.rules?.[TURBO_GLOB]?.loaders ?? [],
22
+ {
23
+ loader,
24
+ options: config
25
+ }
26
+ ]
27
+ }
28
+ }
29
+ };
30
+ return {
31
+ ...nextConfig,
32
+ webpack (conf, options) {
33
+ const resolvedWebpackConfig = typeof nextConfig?.webpack === 'function' ? nextConfig?.webpack(conf, options) : conf;
34
+ resolvedWebpackConfig?.module?.rules?.push({
35
+ test: /\.(js|jsx|ts|tsx)$/,
36
+ exclude: /node_modules/,
37
+ use: {
38
+ loader,
39
+ options: config
40
+ }
41
+ });
42
+ return resolvedWebpackConfig;
43
+ },
44
+ ...IS_CANARY ? {
45
+ experimental: {
46
+ ...nextConfig?.experimental,
47
+ turbo: turboConfig
48
+ }
49
+ } : {
50
+ turbo: turboConfig
51
+ }
52
+ };
53
+ }
54
+
55
+ export { withCxx };
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'vite';
2
+ import { Config } from '../inject/index.js';
3
+
4
+ declare function vitePluginCxx(config?: Config): Plugin;
5
+
6
+ export { vitePluginCxx as default };
@@ -0,0 +1,16 @@
1
+ import { inject } from '../inject/index.js';
2
+
3
+ function vitePluginCxx(config) {
4
+ return {
5
+ name: 'cxx',
6
+ enforce: 'pre',
7
+ transform (code, id) {
8
+ return {
9
+ code: inject(code, id, config),
10
+ map: null
11
+ };
12
+ }
13
+ };
14
+ }
15
+
16
+ export { vitePluginCxx as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jk2908/cxx",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "author": "Jerome Kenway",
6
6
  "repository": {
@@ -10,7 +10,8 @@
10
10
  "main": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts",
12
12
  "scripts": {
13
- "build": "bunchee"
13
+ "build": "bunchee",
14
+ "prepack": "npm run build"
14
15
  },
15
16
  "devDependencies": {
16
17
  "@biomejs/biome": "^1.8.3",