@promoboxx/react-scripts-vite 0.1.30-rc.7 → 0.1.30-rc.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.
@@ -38,12 +38,8 @@ function spawnAndExit(command2, args2 = [], env) {
38
38
  });
39
39
  }
40
40
  const [
41
- // We should probably change our eslint config to ignore unused variables that
42
- // start with an underscore. TypeScript ignores them, Rust ignores, them, it's
43
- // been a convention for almost two decades.
44
- // https://stackoverflow.com/a/77067927
45
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
41
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
42
  _interpreter,
47
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
44
  _thisFile, command, ...args] = process.argv;
49
45
  main(command, args);
@@ -0,0 +1,38 @@
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="vite-plugin-svgr/client" />
3
+ /// <reference types="vitest/globals" />
4
+
5
+ // https://github.com/antfu/vite-plugin-pwa/blob/951311fa811b8cee98ea5530522961f64645cd75/client.d.ts
6
+ // declare module 'virtual:pwa-register' {
7
+ // export type RegisterSWOptions = {
8
+ // immediate?: boolean
9
+ // onNeedRefresh?: () => void
10
+ // onOfflineReady?: () => void
11
+ // onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
12
+ // onRegisterError?: (error: any) => void
13
+ // }
14
+
15
+ // export function registerSW(
16
+ // options?: RegisterSWOptions,
17
+ // ): (reloadPage?: boolean) => Promise<void>
18
+ // }
19
+
20
+ // https://github.com/antfu/vite-plugin-pwa/blob/951311fa811b8cee98ea5530522961f64645cd75/client.d.ts
21
+ // declare module 'virtual:pwa-register/react' {
22
+ // // @ts-ignore ignore when react is not installed
23
+ // import { Dispatch, SetStateAction } from 'react'
24
+
25
+ // export type RegisterSWOptions = {
26
+ // immediate?: boolean
27
+ // onNeedRefresh?: () => void
28
+ // onOfflineReady?: () => void
29
+ // onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
30
+ // onRegisterError?: (error: any) => void
31
+ // }
32
+
33
+ // export function useRegisterSW(options?: RegisterSWOptions): {
34
+ // needRefresh: [boolean, Dispatch<SetStateAction<boolean>>]
35
+ // offlineReady: [boolean, Dispatch<SetStateAction<boolean>>]
36
+ // updateServiceWorker: (reloadPage?: boolean) => Promise<void>
37
+ // }
38
+ // }
@@ -1,8 +1,8 @@
1
- import { type Plugin } from 'vite';
1
+ import { Plugin } from 'vite';
2
2
  /**
3
3
  * Replace env variables in index.html
4
4
  * @see https://github.com/vitejs/vite/issues/3105#issuecomment-939703781
5
5
  * @see https://vitejs.dev/guide/api-plugin.html#transformindexhtml
6
6
  */
7
- declare function replaceEnvInHtml(): Plugin<any>;
7
+ declare function replaceEnvInHtml(): Plugin;
8
8
  export default replaceEnvInHtml;
@@ -12,8 +12,8 @@ function replaceEnvInHtml() {
12
12
  config = resolvedConfig;
13
13
  },
14
14
  transformIndexHtml: {
15
- order: "pre",
16
- handler(html) {
15
+ enforce: "pre",
16
+ transform(html) {
17
17
  return html.replace(/%(.*?)%/g, (match, envVarName) => config?.env?.[envVarName] ?? match);
18
18
  }
19
19
  }
@@ -1,15 +1,14 @@
1
1
  import react from '@vitejs/plugin-react';
2
- import { type UserConfigFn } from 'vite';
2
+ import { UserConfigFn } from 'vite';
3
3
  import pluginChecker from 'vite-plugin-checker';
4
- import * as envCompatibleDefault from 'vite-plugin-env-compatible';
4
+ import envCompatible from 'vite-plugin-environment';
5
5
  import { VitePWA } from 'vite-plugin-pwa';
6
6
  import svgr from 'vite-plugin-svgr';
7
7
  import tsconfigPaths from 'vite-tsconfig-paths';
8
- declare const envCompatible: typeof envCompatibleDefault.default;
9
8
  interface ReactScriptsViteOptions {
10
9
  react?: false | Parameters<typeof react>[0];
11
10
  svgr?: false | Parameters<typeof svgr>[0];
12
- envCompatible?: false | Parameters<typeof envCompatible>[0];
11
+ envCompatible?: false | Parameters<typeof envCompatible>[1];
13
12
  tsconfigPaths?: false | Parameters<typeof tsconfigPaths>[0];
14
13
  pwa?: false | Parameters<typeof VitePWA>[0];
15
14
  checker: false | Parameters<typeof pluginChecker>[0];
@@ -7,15 +7,12 @@ exports.pluginOptions = exports.default = void 0;
7
7
  var _fs = _interopRequireDefault(require("fs"));
8
8
  var _pluginReact = _interopRequireDefault(require("@vitejs/plugin-react"));
9
9
  var _vitePluginChecker = _interopRequireDefault(require("vite-plugin-checker"));
10
- var envCompatibleDefault = _interopRequireWildcard(require("vite-plugin-env-compatible"));
10
+ var _vitePluginEnvironment = _interopRequireDefault(require("vite-plugin-environment"));
11
11
  var _vitePluginPwa = require("vite-plugin-pwa");
12
12
  var _vitePluginSvgr = _interopRequireDefault(require("vite-plugin-svgr"));
13
13
  var _viteTsconfigPaths = _interopRequireDefault(require("vite-tsconfig-paths"));
14
14
  var _replaceEnvInHtml = _interopRequireDefault(require("./replaceEnvInHtml"));
15
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
- const envCompatible = envCompatibleDefault.default;
19
16
  const pluginOptions = exports.pluginOptions = {
20
17
  checker: {
21
18
  eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
@@ -53,7 +50,7 @@ const viteConfig = () => {
53
50
  // React specific.
54
51
  pluginOptions.react === false ? null : (0, _pluginReact.default)(pluginOptions.react), pluginOptions.svgr === false ? null : (0, _vitePluginSvgr.default)(pluginOptions.svgr),
55
52
  // import.meta.env -> process.env
56
- pluginOptions.envCompatible === false ? null : envCompatible(pluginOptions.envCompatible),
53
+ pluginOptions.envCompatible === false ? null : (0, _vitePluginEnvironment.default)("all", pluginOptions.envCompatible),
57
54
  // Support TypeScript paths.
58
55
  pluginOptions.tsconfigPaths === false ? null : (0, _viteTsconfigPaths.default)(pluginOptions.tsconfigPaths),
59
56
  // PWA.
package/dist/client.d.ts CHANGED
@@ -1,5 +1,38 @@
1
1
  /// <reference types="vite/client" />
2
2
  /// <reference types="vite-plugin-svgr/client" />
3
3
  /// <reference types="vitest/globals" />
4
- /// <reference types="vite-plugin-pwa/vanillajs" />
5
- /// <reference types="vite-plugin-pwa/react" />
4
+
5
+ // https://github.com/antfu/vite-plugin-pwa/blob/951311fa811b8cee98ea5530522961f64645cd75/client.d.ts
6
+ // declare module 'virtual:pwa-register' {
7
+ // export type RegisterSWOptions = {
8
+ // immediate?: boolean
9
+ // onNeedRefresh?: () => void
10
+ // onOfflineReady?: () => void
11
+ // onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
12
+ // onRegisterError?: (error: any) => void
13
+ // }
14
+
15
+ // export function registerSW(
16
+ // options?: RegisterSWOptions,
17
+ // ): (reloadPage?: boolean) => Promise<void>
18
+ // }
19
+
20
+ // https://github.com/antfu/vite-plugin-pwa/blob/951311fa811b8cee98ea5530522961f64645cd75/client.d.ts
21
+ // declare module 'virtual:pwa-register/react' {
22
+ // // @ts-ignore ignore when react is not installed
23
+ // import { Dispatch, SetStateAction } from 'react'
24
+
25
+ // export type RegisterSWOptions = {
26
+ // immediate?: boolean
27
+ // onNeedRefresh?: () => void
28
+ // onOfflineReady?: () => void
29
+ // onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
30
+ // onRegisterError?: (error: any) => void
31
+ // }
32
+
33
+ // export function useRegisterSW(options?: RegisterSWOptions): {
34
+ // needRefresh: [boolean, Dispatch<SetStateAction<boolean>>]
35
+ // offlineReady: [boolean, Dispatch<SetStateAction<boolean>>]
36
+ // updateServiceWorker: (reloadPage?: boolean) => Promise<void>
37
+ // }
38
+ // }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -33,13 +33,9 @@ function spawnAndExit(command2, args2 = [], env) {
33
33
  });
34
34
  }
35
35
  const [
36
- // We should probably change our eslint config to ignore unused variables that
37
- // start with an underscore. TypeScript ignores them, Rust ignores, them, it's
38
- // been a convention for almost two decades.
39
- // https://stackoverflow.com/a/77067927
40
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
36
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
37
  _interpreter,
42
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
38
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
43
39
  _thisFile,
44
40
  command,
45
41
  ...args
@@ -0,0 +1,38 @@
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="vite-plugin-svgr/client" />
3
+ /// <reference types="vitest/globals" />
4
+
5
+ // https://github.com/antfu/vite-plugin-pwa/blob/951311fa811b8cee98ea5530522961f64645cd75/client.d.ts
6
+ // declare module 'virtual:pwa-register' {
7
+ // export type RegisterSWOptions = {
8
+ // immediate?: boolean
9
+ // onNeedRefresh?: () => void
10
+ // onOfflineReady?: () => void
11
+ // onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
12
+ // onRegisterError?: (error: any) => void
13
+ // }
14
+
15
+ // export function registerSW(
16
+ // options?: RegisterSWOptions,
17
+ // ): (reloadPage?: boolean) => Promise<void>
18
+ // }
19
+
20
+ // https://github.com/antfu/vite-plugin-pwa/blob/951311fa811b8cee98ea5530522961f64645cd75/client.d.ts
21
+ // declare module 'virtual:pwa-register/react' {
22
+ // // @ts-ignore ignore when react is not installed
23
+ // import { Dispatch, SetStateAction } from 'react'
24
+
25
+ // export type RegisterSWOptions = {
26
+ // immediate?: boolean
27
+ // onNeedRefresh?: () => void
28
+ // onOfflineReady?: () => void
29
+ // onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
30
+ // onRegisterError?: (error: any) => void
31
+ // }
32
+
33
+ // export function useRegisterSW(options?: RegisterSWOptions): {
34
+ // needRefresh: [boolean, Dispatch<SetStateAction<boolean>>]
35
+ // offlineReady: [boolean, Dispatch<SetStateAction<boolean>>]
36
+ // updateServiceWorker: (reloadPage?: boolean) => Promise<void>
37
+ // }
38
+ // }
@@ -0,0 +1 @@
1
+ export { default as viteConfig, pluginOptions } from './viteConfig';
@@ -0,0 +1,8 @@
1
+ import { Plugin } from 'vite';
2
+ /**
3
+ * Replace env variables in index.html
4
+ * @see https://github.com/vitejs/vite/issues/3105#issuecomment-939703781
5
+ * @see https://vitejs.dev/guide/api-plugin.html#transformindexhtml
6
+ */
7
+ declare function replaceEnvInHtml(): Plugin;
8
+ export default replaceEnvInHtml;
@@ -6,8 +6,8 @@ function replaceEnvInHtml() {
6
6
  config = resolvedConfig;
7
7
  },
8
8
  transformIndexHtml: {
9
- order: "pre",
10
- handler(html) {
9
+ enforce: "pre",
10
+ transform(html) {
11
11
  return html.replace(
12
12
  /%(.*?)%/g,
13
13
  (match, envVarName) => config?.env?.[envVarName] ?? match
@@ -0,0 +1,19 @@
1
+ import react from '@vitejs/plugin-react';
2
+ import { UserConfigFn } from 'vite';
3
+ import pluginChecker from 'vite-plugin-checker';
4
+ import envCompatible from 'vite-plugin-environment';
5
+ import { VitePWA } from 'vite-plugin-pwa';
6
+ import svgr from 'vite-plugin-svgr';
7
+ import tsconfigPaths from 'vite-tsconfig-paths';
8
+ interface ReactScriptsViteOptions {
9
+ react?: false | Parameters<typeof react>[0];
10
+ svgr?: false | Parameters<typeof svgr>[0];
11
+ envCompatible?: false | Parameters<typeof envCompatible>[1];
12
+ tsconfigPaths?: false | Parameters<typeof tsconfigPaths>[0];
13
+ pwa?: false | Parameters<typeof VitePWA>[0];
14
+ checker: false | Parameters<typeof pluginChecker>[0];
15
+ envPrefix?: string;
16
+ }
17
+ export declare const pluginOptions: ReactScriptsViteOptions;
18
+ declare const viteConfig: UserConfigFn;
19
+ export default viteConfig;
@@ -1,12 +1,11 @@
1
1
  import fs from "fs";
2
2
  import react from "@vitejs/plugin-react";
3
3
  import pluginChecker from "vite-plugin-checker";
4
- import * as envCompatibleDefault from "vite-plugin-env-compatible";
4
+ import envCompatible from "vite-plugin-environment";
5
5
  import { VitePWA } from "vite-plugin-pwa";
6
6
  import svgr from "vite-plugin-svgr";
7
7
  import tsconfigPaths from "vite-tsconfig-paths";
8
8
  import replaceEnvInHtml from "./replaceEnvInHtml.mjs";
9
- const envCompatible = envCompatibleDefault.default;
10
9
  export const pluginOptions = {
11
10
  checker: {
12
11
  eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
@@ -45,7 +44,7 @@ const viteConfig = () => {
45
44
  pluginOptions.react === false ? null : react(pluginOptions.react),
46
45
  pluginOptions.svgr === false ? null : svgr(pluginOptions.svgr),
47
46
  // import.meta.env -> process.env
48
- pluginOptions.envCompatible === false ? null : envCompatible(pluginOptions.envCompatible),
47
+ pluginOptions.envCompatible === false ? null : envCompatible("all", pluginOptions.envCompatible),
49
48
  // Support TypeScript paths.
50
49
  pluginOptions.tsconfigPaths === false ? null : tsconfigPaths(pluginOptions.tsconfigPaths),
51
50
  // PWA.
package/package.json CHANGED
@@ -1,48 +1,49 @@
1
1
  {
2
2
  "name": "@promoboxx/react-scripts-vite",
3
- "version": "0.1.30-rc.7",
3
+ "version": "0.1.30-rc.9",
4
4
  "description": "",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.mjs",
7
7
  "keywords": [],
8
8
  "repository": {
9
9
  "url": "https://github.com/promoboxx/react-scripts-vite"
10
10
  },
11
11
  "bin": {
12
- "react-scripts": "./dist/cli.js",
13
- "react-scripts-vite": "./dist/cli.js",
14
- "react-scripts-esm": "./dist/cli.mjs",
15
- "react-scripts-vite-esm": "./dist/cli.mjs"
12
+ "react-scripts": "./dist/cjs/cli.js",
13
+ "react-scripts-vite": "./dist/cjs/cli.js",
14
+ "react-scripts-esm": "./dist/esm/cli.mjs",
15
+ "react-scripts-vite-esm": "./dist/esm/cli.mjs"
16
16
  },
17
17
  "author": "",
18
18
  "license": "ISC",
19
19
  "devDependencies": {
20
- "@promoboxx/eslint-config": "^3.1.0",
21
- "prettier": "^3.1.0",
20
+ "@promoboxx/eslint-config": "^3.0.1",
21
+ "concurrently": "^8.2.2",
22
+ "prettier": "^3.0.3",
22
23
  "typescript": "^5.2.2",
23
24
  "unbuild": "^2.0.0"
24
25
  },
25
26
  "exports": {
26
27
  ".": {
27
- "import": "./dist/index.mjs",
28
- "require": "./dist/index.js"
28
+ "import": "./dist/cjs/index.mjs",
29
+ "require": "./dist/esm/index.js"
29
30
  },
30
31
  "./*": {
31
- "import": "./dist/*.mjs",
32
- "require": "./dist/*.js"
32
+ "import": "./*.mjs",
33
+ "require": "./*.js"
33
34
  }
34
35
  },
35
36
  "dependencies": {
36
- "@vitejs/plugin-react": "^4.2.0",
37
- "eslint": "^8.54.0",
37
+ "@vitejs/plugin-react": "^4.1.0",
38
+ "eslint": "^8.50.0",
38
39
  "jsdom": "^22.1.0",
39
- "vite": "^5.0.0",
40
+ "vite": "^4.4.9",
40
41
  "vite-plugin-checker": "^0.6.2",
41
- "vite-plugin-env-compatible": "^1.1.1",
42
- "vite-plugin-pwa": "^0.17.0",
43
- "vite-plugin-svgr": "^4.2.0",
42
+ "vite-plugin-environment": "^1.1.3",
43
+ "vite-plugin-pwa": "^0.16.5",
44
+ "vite-plugin-svgr": "^4.0.0",
44
45
  "vite-tsconfig-paths": "^4.2.1",
45
- "vitest": "^0.34.6"
46
+ "vitest": "^0.34.5"
46
47
  },
47
48
  "files": [
48
49
  "dist/**/*"
File without changes
File without changes
File without changes
File without changes