@temir.ra/create-ts-lib 0.11.0 → 0.12.0-pre.1
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.
- package/CHANGELOG.md +8 -0
- package/README.md +19 -7
- package/buildinfo.txt +1 -1
- package/package.json +1 -1
- package/template/README.md +2 -2
- package/template/package.json +1 -1
- package/template/scripts/build-bundle.ts +8 -8
- package/template/scripts/import-map.json +1 -0
- package/template/scripts/cdn-rewrite-map.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Version 0
|
|
2
2
|
|
|
3
|
+
## 0.12.0-pre.1
|
|
4
|
+
|
|
5
|
+
1. Refactored `scripts/build-bundle.ts` to use an import map plugin instead of a CDN rewrite plugin.
|
|
6
|
+
|
|
7
|
+
## 0.11.1
|
|
8
|
+
|
|
9
|
+
1. Updated from `template@0.4.1` template.
|
|
10
|
+
|
|
3
11
|
## 0.11.0
|
|
4
12
|
|
|
5
13
|
1. Synced template files with `workspace@0.7.0-pre.1` template.
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ A template for TypeScript libraries distributed via npm-compatible registries. P
|
|
|
8
8
|
2. [Documentation](#documentation)
|
|
9
9
|
1. [`package.json`](#packagejson)
|
|
10
10
|
2. [Script `scripts/build-bundle.ts`](#script-scriptsbuild-bundlets)
|
|
11
|
-
1. [
|
|
11
|
+
1. [Import Map `scripts/import-map.json`](#import-map-scriptsimport-mapjson)
|
|
12
12
|
3. [`tsconfig.build.json`](#tsconfigbuildjson)
|
|
13
13
|
4. [Asset Resolution](#asset-resolution)
|
|
14
14
|
1. [Externalized - loaded from CDN or `node_modules/`](#externalized---loaded-from-cdn-or-node_modules)
|
|
@@ -38,7 +38,7 @@ npm create --no-install --no-git "@temir.ra/ts-lib@latest" .
|
|
|
38
38
|
|
|
39
39
|
# set metadata in package.json
|
|
40
40
|
|
|
41
|
-
npm
|
|
41
|
+
npm update
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
# Documentation
|
|
@@ -75,7 +75,7 @@ The following fields are specific to this template:
|
|
|
75
75
|
"files": [
|
|
76
76
|
"scripts/buildinfo.ts",
|
|
77
77
|
"scripts/build-bundle.ts",
|
|
78
|
-
"scripts/
|
|
78
|
+
"scripts/import-map.json",
|
|
79
79
|
"CHANGELOG.md",
|
|
80
80
|
"buildinfo.txt",
|
|
81
81
|
"dist/",
|
|
@@ -157,17 +157,22 @@ The following fields are specific to this template:
|
|
|
157
157
|
|
|
158
158
|
Bundles the library to ESM and IIFE formats using `esbuild`. Entry points are resolved from the `entrypoint` condition in the `exports` field of `package.json`. Note, the `entrypoint` condition is a custom, non-standard export condition used solely for build tooling.
|
|
159
159
|
|
|
160
|
-
Import specifiers can be
|
|
160
|
+
Import specifiers can be mapped to CDN URLs or marked as external via `scripts/import-map.json`.
|
|
161
|
+
|
|
162
|
+
### Import Map `scripts/import-map.json`
|
|
161
163
|
|
|
162
|
-
|
|
164
|
+
Maps import specifiers to CDN URLs or marks them as external without rewriting. During bundling, matching specifiers in source files are resolved according to the map.
|
|
163
165
|
|
|
164
|
-
|
|
166
|
+
- **Truthy value**: rewrites the import to the given URL and marks it external.
|
|
167
|
+
- **Falsy value**: marks the import external without rewriting; the original specifier is preserved.
|
|
165
168
|
|
|
166
169
|
`<VERSION>` in a URL is replaced with the version of the matching package from `package.json`.
|
|
167
170
|
|
|
168
171
|
```json
|
|
169
172
|
{
|
|
170
|
-
"
|
|
173
|
+
"rewrite-package": "https://cdn.jsdelivr.net/npm/rewrite-package@<VERSION>/dist/index.js",
|
|
174
|
+
"rewrite-package-without-version": "https://cdn.jsdelivr.net/npm/rewrite-package/dist/index.js",
|
|
175
|
+
"external-only-package": null
|
|
171
176
|
}
|
|
172
177
|
```
|
|
173
178
|
|
|
@@ -450,6 +455,13 @@ npmx tsx dist/cli.bundle.js -- example/
|
|
|
450
455
|
@temir.ra:registry=https://registry.npmjs.org/
|
|
451
456
|
```
|
|
452
457
|
|
|
458
|
+
`~/.bunfig.toml` or `bunfig.toml`:
|
|
459
|
+
|
|
460
|
+
```toml
|
|
461
|
+
[install.scopes]
|
|
462
|
+
"temir.ra" = { url = "https://registry.npmjs.org/" }
|
|
463
|
+
```
|
|
464
|
+
|
|
453
465
|
```bash
|
|
454
466
|
# registry.npmjs.org/
|
|
455
467
|
npm login
|
package/buildinfo.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.12.0-pre.1+78f65d1
|
package/package.json
CHANGED
package/template/README.md
CHANGED
package/template/package.json
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type BuildResult
|
|
12
12
|
} from 'esbuild';
|
|
13
13
|
|
|
14
|
-
import
|
|
14
|
+
import IMPORT_MAP from './import-map.json';
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
interface ExportConditions {
|
|
@@ -122,20 +122,20 @@ const esbuildLog: EsbuildPlugin = {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
const
|
|
126
|
-
name: '
|
|
125
|
+
const importMap: EsbuildPlugin = {
|
|
126
|
+
name: 'import-map',
|
|
127
127
|
setup(build: PluginBuild) {
|
|
128
128
|
|
|
129
|
-
for (const [importSpecifier, urlTemplate] of Object.entries(
|
|
129
|
+
for (const [importSpecifier, urlTemplate] of Object.entries(IMPORT_MAP) as [string, string | null][]) {
|
|
130
130
|
|
|
131
|
-
const url = resolveVersionInCdnUrl(importSpecifier, urlTemplate);
|
|
132
|
-
console.log(`[
|
|
131
|
+
const url = urlTemplate ? resolveVersionInCdnUrl(importSpecifier, urlTemplate) : null;
|
|
132
|
+
console.log(`[import-map plugin] '${importSpecifier}' → ${url ? `'${url}'` : 'external (no rewrite)'}`);
|
|
133
133
|
|
|
134
134
|
const escapedSpecifier = importSpecifier.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
135
135
|
build.onResolve(
|
|
136
136
|
{ filter: new RegExp(`^${escapedSpecifier}$`) },
|
|
137
137
|
(args: OnResolveArgs): OnResolveResult | undefined => {
|
|
138
|
-
return { path: url, external: true };
|
|
138
|
+
return { path: url ?? args.path, external: true };
|
|
139
139
|
}
|
|
140
140
|
);
|
|
141
141
|
|
|
@@ -157,7 +157,7 @@ const buildOptions: BuildOptions = {
|
|
|
157
157
|
bundle: true,
|
|
158
158
|
minify: true,
|
|
159
159
|
sourcemap: 'external',
|
|
160
|
-
plugins: [esbuildLog,
|
|
160
|
+
plugins: [esbuildLog, importMap],
|
|
161
161
|
|
|
162
162
|
};
|
|
163
163
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|