diff --git a/README.md b/README.md index 58b5059..7c53462 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,9 @@ A good way to host your repo image is to open an issue named ASSET in your proje While you are at it submit this image as *social preview* in your repos github page's settings so that when you share on Twitter or Reddit you don't get your GitHub profile picture to show up. -## Disable CDN build +## Disable CDN build + +### Completely disable If your project does not target the browser or if you are not interested in offering CDN distribution: @@ -89,6 +91,40 @@ If your project does not target the browser or if you are not interested in offe - Remove ``/dist/esm/`` entry from ``files`` in ``package.json`` - Remove ``simplifyify`` and ``terser`` from dev dependencies. +### Only disable ES Module build ( ``dist/zz_esm/*`` ) + +If ``npm run build`` fail because ``tsc -p tsconfig.esm.json`` gives errors you may want to remove the ESM +build but keep the ``bundle.js`` and ``bundle.min.js``. To do that: + +In ``package.json`` replace theses ``scripts``: + +```json +{ + "cdn:bundle:.js": "simplifyify dist/index.js -s #{REPO_NAME}# -o dist/bundle.js --debug --bundle", + "cdn:bundle:.min.js": "terser dist/bundle.js -cmo dist/bundle.min.js", + "cdn:bundle": "npm run cdn:bundle:.js && npm run cdn:bundle:.min.js", + "cdn:esm": "tsc -p tsconfig.esm.json", + "cdn": "npm run cdn:bundle && npm run cdn:esm", +} +``` + +By theses ones: + +```json +{ + "cdn:.js": "simplifyify dist/index.js -s #{REPO_NAME}# -o dist/bundle.js --debug --bundle", + "cdn:.min.js": "terser dist/bundle.js -cmo dist/bundle.min.js", + "cdn": "npm run cdn:.js && npm run cdn:.min.js", +} +``` + +Remove the ``/dist/zz_esm/`` entry from ``package.json``'s ``files``. + +Remove ``tsconfig.esm.json``. ( file at the root of the project ) + +Edit the ``README.md`` to remove instructions about how to +import as ES module. + ## Remove unwanted dev dependencies Dev dependencies that are not required by the template ( you can safely remove them if you don't use them ): diff --git a/README.template.md b/README.template.md index b4265a5..76a09b7 100644 --- a/README.template.md +++ b/README.template.md @@ -35,18 +35,18 @@ import { myFunction } from '#{REPO_NAME}#/myFunction'; import { myObject } from '#{REPO_NAME}#/myObject'; ``` -## From HTML with CDN +## Import from HTML, with CDN -Expose a global (wider browser support): +Import it via a bundle that creates a global ( wider browser support ): ```html - + ``` -Or import as an ES module: +Or import it as an ES module: ```html ``` +*You can specify the version you wish to import: * [unpkg.com](https://unpkg.com) + ## Contribute ```bash diff --git a/package.json b/package.json index 046d8ec..712f52c 100755 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "scripts": { "test": "node ./dist/test", "tsc": "npx tsc", - "cdn:bundle:.js": "simplifyify dist/index.js -s #{REPO_NAME_NO_DASHES}# -o dist/umd_bundle.js --debug --bundle", - "cdn:bundle:.min.js": "terser dist/umd_bundle.js -cmo dist/umd_bundle.min.js", + "cdn:bundle:.js": "simplifyify dist/index.js -s #{REPO_NAME}# -o dist/bundle.js --debug --bundle", + "cdn:bundle:.min.js": "terser dist/bundle.js -cmo dist/bundle.min.js", "cdn:bundle": "npm run cdn:bundle:.js && npm run cdn:bundle:.min.js", "cdn:esm": "tsc -p tsconfig.esm.json", "cdn": "npm run cdn:bundle && npm run cdn:esm", @@ -24,10 +24,11 @@ "license": "MIT", "homepage": "https://github.com/#{USER_OR_ORG}#/#{REPO_NAME}#", "files": [ - "/src/", "/dist/*.{d.ts,js,js.map}", "/dist/tools/", - "/dist/zz_esm/" + "/dist/zz_esm/", + "/src/*.ts", + "/src/tools/" ], "keywords": [], "devDependencies": { @@ -38,4 +39,4 @@ "simplifyify": "8.0.1", "terser": "4.6.13" } -} +} \ No newline at end of file