@react-foundry/vite-html-react 0.1.9 → 0.2.0

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.
Files changed (2) hide show
  1. package/package.json +2 -5
  2. package/dist/index.cjs +0 -41
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-foundry/vite-html-react",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "A Vite plugin for importing HTML files as React components.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -9,7 +9,6 @@
9
9
  ".": {
10
10
  "types": "./types/index.d.ts",
11
11
  "import": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
12
  "default": "./dist/index.js"
14
13
  }
15
14
  },
@@ -31,9 +30,7 @@
31
30
  },
32
31
  "scripts": {
33
32
  "test": "NODE_OPTIONS=--experimental-vm-modules jest",
34
- "build": "npm run build:cjs && npm run build:esm",
35
- "build:esm": "tsc -m es2022",
36
- "build:cjs": "tsc -m commonjs && find dist -name '*.js' -exec sh -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;",
33
+ "build": "tsc",
37
34
  "clean": "rm -rf dist tsconfig.tsbuildinfo"
38
35
  },
39
36
  "module": "dist/index.js"
package/dist/index.cjs DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.htmlReact = void 0;
4
- const defaultExtensions = [
5
- '.htm'
6
- ];
7
- const htmlReact = (options = {
8
- extensions: defaultExtensions
9
- }) => {
10
- const { extensions = defaultExtensions } = options;
11
- const isMatch = (id) => extensions.reduce((acc, cur) => acc || id.endsWith(cur), false);
12
- return {
13
- name: 'html-react',
14
- transform(_code, id) {
15
- if (!isMatch(id))
16
- return;
17
- const code = jsWrap(_code);
18
- return {
19
- code,
20
- map: null
21
- };
22
- }
23
- };
24
- };
25
- exports.htmlReact = htmlReact;
26
- const jsWrap = (html) => {
27
- const clean = (JSON.stringify(html)
28
- .replace(/\u2028/g, '\\u2028')
29
- .replace(/\u2029/g, '\\u2029'));
30
- return `//HTML
31
- import { createElement as h } from 'react';
32
-
33
- const html = ${clean};
34
- const HtmlComponent = () => h('div', {
35
- dangerouslySetInnerHTML: { __html: html }
36
- });
37
-
38
- export default HtmlComponent;
39
- `;
40
- };
41
- exports.default = exports.htmlReact;