From fb5ed9c0d08018f24f7fcf6041a3507adc3a3054 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sun, 12 Jul 2020 14:01:57 +0200 Subject: [PATCH] :wrench: Export file to CJS --- package.json | 4 +- playground/src/main.tsx | 2 + playground/vite.config.ts | 2 +- pnpm-lock.yaml | 89 ++++++++++++++++++++++++--------------- tsconfig.json | 2 +- 5 files changed, 60 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index e638fad..1f138ea 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "access": "public" }, "files": [ - "lib/" + "lib" ], - "types": "lib", + "types": "lib/plugin.d.ts", "scripts": { "build": "tsc" }, diff --git a/playground/src/main.tsx b/playground/src/main.tsx index 1ca3d67..3d9f073 100644 --- a/playground/src/main.tsx +++ b/playground/src/main.tsx @@ -6,6 +6,8 @@ const rootEl = document.getElementById("app"); const dispose = render(() => App, rootEl); // HMR stuff, this will be automatically removed during build +// /!\ You need to add "vite" in the "compilerOptions.types" of your tsconfig.json +// if you want to avoid type errors here if (import.meta.hot) { import.meta.hot.accept(); import.meta.hot.dispose(() => { diff --git a/playground/vite.config.ts b/playground/vite.config.ts index 92579af..998a2c4 100644 --- a/playground/vite.config.ts +++ b/playground/vite.config.ts @@ -1,5 +1,5 @@ import { UserConfig } from "vite"; -import { solidPlugin } from "../lib/plugin"; +const { solidPlugin } = require("../lib/plugin"); // This should work witrh import {} from '..' const config: UserConfig = { root: "src", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bd330c9..2693bd1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,18 +1,19 @@ dependencies: - vite: 1.0.0-beta.11 -devDependencies: '@babel/core': 7.10.4 '@babel/preset-typescript': 7.10.4_@babel+core@7.10.4 '@rollup/plugin-babel': 5.0.4_@babel+core@7.10.4 - '@types/babel__core': 7.1.9 babel-preset-solid: 0.18.12_@babel+core@7.10.4 solid-js: 0.18.12 + vite: 1.0.0-beta.11 +devDependencies: + '@types/babel__core': 7.1.9 typescript: 4.0.0-dev.20200712 lockfileVersion: 5.1 packages: /@babel/code-frame/7.10.4: dependencies: '@babel/highlight': 7.10.4 + dev: false resolution: integrity: sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== /@babel/core/7.10.4: @@ -33,7 +34,7 @@ packages: resolve: 1.17.0 semver: 5.7.1 source-map: 0.5.7 - dev: true + dev: false engines: node: '>=6.9.0' resolution: @@ -44,7 +45,7 @@ packages: jsesc: 2.5.2 lodash: 4.17.19 source-map: 0.5.7 - dev: true + dev: false resolution: integrity: sha512-toLIHUIAgcQygFZRAQcsLQV3CBuX6yOIru1kJk/qqqvcRmZrYe6WavZTSG+bB8MxhnL9YPf+pKQfuiP161q7ng== /@babel/helper-create-class-features-plugin/7.10.4_@babel+core@7.10.4: @@ -56,7 +57,7 @@ packages: '@babel/helper-plugin-utils': 7.10.4 '@babel/helper-replace-supers': 7.10.4 '@babel/helper-split-export-declaration': 7.10.4 - dev: true + dev: false peerDependencies: '@babel/core': ^7.0.0 resolution: @@ -66,25 +67,25 @@ packages: '@babel/helper-get-function-arity': 7.10.4 '@babel/template': 7.10.4 '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ== /@babel/helper-get-function-arity/7.10.4: dependencies: '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A== /@babel/helper-member-expression-to-functions/7.10.4: dependencies: '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-m5j85pK/KZhuSdM/8cHUABQTAslV47OjfIB9Cc7P+PvlAoBzdb79BGNfw8RhT5Mq3p+xGd0ZfAKixbrUZx0C7A== /@babel/helper-module-imports/7.10.4: dependencies: '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw== /@babel/helper-module-transforms/7.10.4: @@ -96,17 +97,17 @@ packages: '@babel/template': 7.10.4 '@babel/types': 7.10.4 lodash: 4.17.19 - dev: true + dev: false resolution: integrity: sha512-Er2FQX0oa3nV7eM1o0tNCTx7izmQtwAQsIiaLRWtavAAEcskb0XJ5OjJbVrYXWOTr8om921Scabn4/tzlx7j1Q== /@babel/helper-optimise-call-expression/7.10.4: dependencies: '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg== /@babel/helper-plugin-utils/7.10.4: - dev: true + dev: false resolution: integrity: sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg== /@babel/helper-replace-supers/7.10.4: @@ -115,20 +116,20 @@ packages: '@babel/helper-optimise-call-expression': 7.10.4 '@babel/traverse': 7.10.4 '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-sPxZfFXocEymYTdVK1UNmFPBN+Hv5mJkLPsYWwGBxZAxaWfFu+xqp7b6qWD0yjNuNL2VKc6L5M18tOXUP7NU0A== /@babel/helper-simple-access/7.10.4: dependencies: '@babel/template': 7.10.4 '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-0fMy72ej/VEvF8ULmX6yb5MtHG4uH4Dbd6I/aHDb/JVg0bbivwt9Wg+h3uMvX+QSFtwr5MeItvazbrc4jtRAXw== /@babel/helper-split-export-declaration/7.10.4: dependencies: '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-pySBTeoUff56fL5CBU2hWm9TesA4r/rOkI9DyJLvvgz09MB9YtfIYe3iBriVaYNaPe+Alua0vBIOVOLs2buWhg== /@babel/helper-validator-identifier/7.10.4: @@ -139,7 +140,7 @@ packages: '@babel/template': 7.10.4 '@babel/traverse': 7.10.4 '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA== /@babel/highlight/7.10.4: @@ -147,6 +148,7 @@ packages: '@babel/helper-validator-identifier': 7.10.4 chalk: 2.4.2 js-tokens: 4.0.0 + dev: false resolution: integrity: sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== /@babel/parser/7.10.4: @@ -159,7 +161,7 @@ packages: dependencies: '@babel/core': 7.10.4 '@babel/helper-plugin-utils': 7.10.4 - dev: true + dev: false peerDependencies: '@babel/core': ^7.0.0-0 resolution: @@ -168,7 +170,7 @@ packages: dependencies: '@babel/core': 7.10.4 '@babel/helper-plugin-utils': 7.10.4 - dev: true + dev: false peerDependencies: '@babel/core': ^7.0.0-0 resolution: @@ -179,7 +181,7 @@ packages: '@babel/helper-create-class-features-plugin': 7.10.4_@babel+core@7.10.4 '@babel/helper-plugin-utils': 7.10.4 '@babel/plugin-syntax-typescript': 7.10.4_@babel+core@7.10.4 - dev: true + dev: false peerDependencies: '@babel/core': ^7.0.0-0 resolution: @@ -189,7 +191,7 @@ packages: '@babel/core': 7.10.4 '@babel/helper-plugin-utils': 7.10.4 '@babel/plugin-transform-typescript': 7.10.4_@babel+core@7.10.4 - dev: true + dev: false peerDependencies: '@babel/core': ^7.0.0-0 resolution: @@ -199,7 +201,7 @@ packages: '@babel/code-frame': 7.10.4 '@babel/parser': 7.10.4 '@babel/types': 7.10.4 - dev: true + dev: false resolution: integrity: sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA== /@babel/traverse/7.10.4: @@ -213,7 +215,7 @@ packages: debug: 4.1.1 globals: 11.12.0 lodash: 4.17.19 - dev: true + dev: false resolution: integrity: sha512-aSy7p5THgSYm4YyxNGz6jZpXf+Ok40QF3aA2LyIONkDHpAcJzDUqlCKXv6peqYUs2gmic849C/t2HKw2a2K20Q== /@babel/types/7.10.4: @@ -252,7 +254,7 @@ packages: '@babel/core': 7.10.4 '@babel/helper-module-imports': 7.10.4 '@rollup/pluginutils': 3.1.0 - dev: true + dev: false engines: node: '>= 10.0.0' peerDependencies: @@ -308,7 +310,7 @@ packages: '@types/estree': 0.0.39 estree-walker: 1.0.1 picomatch: 2.2.2 - dev: true + dev: false engines: node: '>= 8.0.0' peerDependencies: @@ -394,6 +396,7 @@ packages: resolution: integrity: sha512-oTGtMzZZAVuEjTwCjIh8T8FrC8n/uwy+PG0yTvQcdZ7etoel7C7/3MSd7qrukENTgQtotG7gvBlBojuVs7X5rw== /@types/estree/0.0.39: + dev: false resolution: integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== /@types/estree/0.0.45: @@ -563,6 +566,7 @@ packages: /ansi-styles/3.2.1: dependencies: color-convert: 1.9.3 + dev: false engines: node: '>=4' resolution: @@ -611,7 +615,7 @@ packages: dependencies: '@babel/helper-module-imports': 7.10.4 '@babel/plugin-syntax-jsx': 7.10.4_@babel+core@7.10.4 - dev: true + dev: false peerDependencies: '@babel/core': '*' resolution: @@ -619,7 +623,7 @@ packages: /babel-preset-solid/0.18.12_@babel+core@7.10.4: dependencies: babel-plugin-jsx-dom-expressions: 0.19.7_@babel+core@7.10.4 - dev: true + dev: false peerDependencies: '@babel/core': '*' resolution: @@ -717,6 +721,7 @@ packages: ansi-styles: 3.2.1 escape-string-regexp: 1.0.5 supports-color: 5.5.0 + dev: false engines: node: '>=4' resolution: @@ -793,6 +798,7 @@ packages: /color-convert/1.9.3: dependencies: color-name: 1.1.3 + dev: false resolution: integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== /color-convert/2.0.1: @@ -804,6 +810,7 @@ packages: resolution: integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== /color-name/1.1.3: + dev: false resolution: integrity: sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= /color-name/1.1.4: @@ -847,7 +854,7 @@ packages: /convert-source-map/1.7.0: dependencies: safe-buffer: 5.1.2 - dev: true + dev: false resolution: integrity: sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== /cookies/0.8.0: @@ -900,6 +907,7 @@ packages: /debug/4.1.1: dependencies: ms: 2.1.2 + dev: false resolution: integrity: sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== /deep-equal/1.0.1: @@ -1007,6 +1015,7 @@ packages: resolution: integrity: sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= /escape-string-regexp/1.0.5: + dev: false engines: node: '>=0.8.0' resolution: @@ -1027,6 +1036,7 @@ packages: resolution: integrity: sha512-H6cJORkqvrNziu0KX2hqOMAlA2CiuAxHeGJXSIoKA/KLv229Dw806J3II6mKTm5xiDX1At1EXCfsOQPB+tMB+g== /estree-walker/1.0.1: + dev: false resolution: integrity: sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== /estree-walker/2.0.1: @@ -1129,7 +1139,7 @@ packages: resolution: integrity: sha512-kPCHWa1m9wGG/OwQpeweTwM/PYiQLrUIxXbt/P4Nic3LbGjCP0YwrALHW1uNLKZ0LIMg+RF+XRlj2ekT9ZlZAQ== /gensync/1.0.0-beta.1: - dev: true + dev: false engines: node: '>=6.9.0' resolution: @@ -1162,7 +1172,7 @@ packages: resolution: integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== /globals/11.12.0: - dev: true + dev: false engines: node: '>=4' resolution: @@ -1185,6 +1195,7 @@ packages: resolution: integrity: sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== /has-flag/3.0.0: + dev: false engines: node: '>=4' resolution: @@ -1438,6 +1449,7 @@ packages: resolution: integrity: sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw== /js-tokens/4.0.0: + dev: false resolution: integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== /js-yaml/3.14.0: @@ -1449,7 +1461,7 @@ packages: resolution: integrity: sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== /jsesc/2.5.2: - dev: true + dev: false engines: node: '>=4' hasBin: true @@ -1469,7 +1481,7 @@ packages: /json5/2.1.3: dependencies: minimist: 1.2.5 - dev: true + dev: false engines: node: '>=6' hasBin: true @@ -1675,6 +1687,7 @@ packages: resolution: integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== /minimist/1.2.5: + dev: false resolution: integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== /ms/2.0.0: @@ -1682,6 +1695,7 @@ packages: resolution: integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= /ms/2.1.2: + dev: false resolution: integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== /mute-stream/0.0.8: @@ -1813,6 +1827,7 @@ packages: resolution: integrity: sha1-pidH88fgwlFHYml/JEQ1hbCRAOo= /path-parse/1.0.6: + dev: false resolution: integrity: sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== /path-to-regexp/1.8.0: @@ -1828,6 +1843,7 @@ packages: resolution: integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== /picomatch/2.2.2: + dev: false engines: node: '>=8.6' resolution: @@ -1986,6 +2002,7 @@ packages: /resolve/1.17.0: dependencies: path-parse: 1.0.6 + dev: false resolution: integrity: sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== /restore-cursor/3.1.0: @@ -2067,6 +2084,7 @@ packages: resolution: integrity: sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q== /safe-buffer/5.1.2: + dev: false resolution: integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== /selfsigned/1.10.7: @@ -2076,7 +2094,7 @@ packages: resolution: integrity: sha512-8M3wBCzeWIJnQfl43IKwOmC4H/RAp50S8DF60znzjW5GVqTcSe2vWclt7hmYVPkKPlHWOu5EaWOMZ2Y6W8ZXTA== /semver/5.7.1: - dev: true + dev: false hasBin: true resolution: integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -2121,7 +2139,7 @@ packages: resolution: integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== /solid-js/0.18.12: - dev: true + dev: false resolution: integrity: sha512-HSOMB9/0AfqJRVBVamNEN4BUbqMLzbOC2tx6XimOwC6Hfopeh1GSJpxPF/HJG4QWnXGnRJDCEr/FWInov1skeg== /source-map-support/0.5.19: @@ -2132,7 +2150,7 @@ packages: resolution: integrity: sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== /source-map/0.5.7: - dev: true + dev: false engines: node: '>=0.10.0' resolution: @@ -2178,6 +2196,7 @@ packages: /supports-color/5.5.0: dependencies: has-flag: 3.0.0 + dev: false engines: node: '>=4' resolution: diff --git a/tsconfig.json b/tsconfig.json index 89a7278..702fb37 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "esModuleInterop": true, "declaration": true, "target": "ES2019", - "module": "ESNext", + "module": "CommonJS", "moduleResolution": "node", "declarationDir": "lib", "forceConsistentCasingInFileNames": true,