Skip to content

Commit

Permalink
Add new lit-dev-tools-esm package
Browse files Browse the repository at this point in the history
The lit-dev-tools package is currently CommonJS, because mostly it
is used for Eleventy plugins, and Eleventy doesn't support ES
modules (11ty/eleventy#836).

We want ES modules for this new redirect checker script, because it
needs to import some ES modules, and that is difficult to do with
TypeScript, because TypeScript doesn't allow emitting an actual
`import` statement, which is how CommonJS -> ESM interop works
(microsoft/TypeScript#43329).

We also an't really have a mix of CommonJS and ESM in the same package,
because the {"type": "module"} field has to be set. We could use
.mjs extensions, but TypeScript won't emit those.

So the simplest solution seems to be to just have two packages!
  • Loading branch information
aomarks committed Sep 1, 2021
1 parent 4d623e0 commit 691ade4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/lit-dev-tools-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "lit-dev-tools-esm",
"private": true,
"version": "0.0.0",
"description": "Misc tools for lit.dev (ES Modules)",
"author": "Google LLC",
"license": "BSD-3-Clause",
"type": "module",
"scripts": {
"build": "npm run build:ts",
"build:ts": "../../node_modules/.bin/tsc",
"format": "../../node_modules/.bin/prettier \"**/*.{ts,js,json,html,css,md}\" --write"
},
"dependencies": {
}
}
22 changes: 22 additions & 0 deletions packages/lit-dev-tools-esm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es2020",
"module": "esnext",
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*.ts"],
"exclude": []
}
2 changes: 1 addition & 1 deletion packages/lit-dev-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lit-dev-tools",
"private": true,
"version": "0.0.0",
"description": "Misc tools for lit.dev",
"description": "Misc tools for lit.dev (CommonJS)",
"author": "Google LLC",
"license": "BSD-3-Clause",
"scripts": {
Expand Down

0 comments on commit 691ade4

Please sign in to comment.