Use ts-loader with webpack to avoid needing to compile lib-es3.

This commit is contained in:
David Anson 2021-01-06 19:45:15 -08:00
parent 868310a094
commit 5838b62e6d
7 changed files with 358 additions and 335 deletions

View file

@ -4,4 +4,3 @@ demo/markdownlint-browser.min.js
demo/markdownlint-rule-helpers-browser.js demo/markdownlint-rule-helpers-browser.js
demo/markdownlint-rule-helpers-browser.min.js demo/markdownlint-rule-helpers-browser.min.js
example/typescript/type-check.js example/typescript/type-check.js
lib-es3/

1
.gitignore vendored
View file

@ -3,7 +3,6 @@ demo/markdown-it.min.js
demo/markdownlint-browser.min.js demo/markdownlint-browser.min.js
demo/markdownlint-browser.min.js.LICENSE.txt demo/markdownlint-browser.min.js.LICENSE.txt
demo/markdownlint-rule-helpers-browser.* demo/markdownlint-rule-helpers-browser.*
lib-es3
node_modules node_modules
!test/node_modules !test/node_modules
npm-debug.log npm-debug.log

View file

@ -8,7 +8,6 @@ coverage
demo/* demo/*
!demo/markdownlint-browser.js !demo/markdownlint-browser.js
example example
lib-es3
npm-debug.log npm-debug.log
test test
test-repos test-repos

File diff suppressed because it is too large Load diff

9
demo/tsconfig.json Normal file
View file

@ -0,0 +1,9 @@
{
"compilerOptions": {
"allowJs": true,
"resolveJsonModule": true
},
"include": [
"../lib/*.js"
]
}

View file

@ -2,6 +2,7 @@
"use strict"; "use strict";
const path = require("path");
const webpack = require("webpack"); const webpack = require("webpack");
function config(options) { function config(options) {
@ -14,6 +15,21 @@ function config(options) {
"markdown-it": "markdownit" "markdown-it": "markdownit"
}, },
"mode": mode, "mode": mode,
"module": {
"rules": [
{
"test": /.js$/,
"use": [
{
"loader": "ts-loader",
"options": {
"configFile": path.resolve(__dirname, "tsconfig.json")
}
}
]
}
]
},
"name": name, "name": name,
"output": { "output": {
"filename": filename, "filename": filename,
@ -41,25 +57,25 @@ function config(options) {
module.exports = [ module.exports = [
config({ config({
"entry": "../lib-es3/lib/markdownlint.js", "entry": "../lib/markdownlint.js",
"filename": "markdownlint-browser.js", "filename": "markdownlint-browser.js",
"mode": "development", "mode": "development",
"packageJson": require("../package.json") "packageJson": require("../package.json")
}), }),
config({ config({
"entry": "../lib-es3/lib/markdownlint.js", "entry": "../lib/markdownlint.js",
"filename": "markdownlint-browser.min.js", "filename": "markdownlint-browser.min.js",
"mode": "production", "mode": "production",
"packageJson": require("../package.json") "packageJson": require("../package.json")
}), }),
config({ config({
"entry": "../lib-es3/helpers/helpers.js", "entry": "../helpers/helpers.js",
"filename": "markdownlint-rule-helpers-browser.js", "filename": "markdownlint-rule-helpers-browser.js",
"mode": "development", "mode": "development",
"packageJson": require("../helpers/package.json") "packageJson": require("../helpers/package.json")
}), }),
config({ config({
"entry": "../lib-es3/helpers/helpers.js", "entry": "../helpers/helpers.js",
"filename": "markdownlint-rule-helpers-browser.min.js", "filename": "markdownlint-rule-helpers-browser.min.js",
"mode": "production", "mode": "production",
"packageJson": require("../helpers/package.json") "packageJson": require("../helpers/package.json")

View file

@ -21,7 +21,7 @@
"ci": "npm run test-cover && npm run lint && npm run build-declaration && npm run test-declaration && npm run build-config-schema && git diff --exit-code", "ci": "npm run test-cover && npm run lint && npm run build-declaration && npm run test-declaration && npm run build-config-schema && git diff --exit-code",
"build-config-schema": "node schema/build-config-schema.js", "build-config-schema": "node schema/build-config-schema.js",
"build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf 'lib/{c,md,r}*.d.ts' 'helpers/*.d.ts'", "build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf 'lib/{c,md,r}*.d.ts' 'helpers/*.d.ts'",
"build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && webpack", "build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && webpack",
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2", "build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
"example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint", "example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint",
"clone-test-repos": "mkdir test-repos && cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet", "clone-test-repos": "mkdir test-repos && cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet",
@ -55,6 +55,7 @@
"tape": "~5.0.1", "tape": "~5.0.1",
"tape-player": "~0.1.1", "tape-player": "~0.1.1",
"toml": "~3.0.0", "toml": "~3.0.0",
"ts-loader": "~8.0.14",
"tv4": "~1.3.0", "tv4": "~1.3.0",
"typescript": "~4.1.2", "typescript": "~4.1.2",
"webpack": "~5.11.1", "webpack": "~5.11.1",