@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 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. [CDN Map `scripts/cdn-rewrite-map.json`](#cdn-map-scriptscdn-rewrite-mapjson)
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 install
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/cdn-rewrite-map.json",
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 rewritten to CDN URLs via `scripts/cdn-rewrite-map.json`.
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
- ### CDN Map `scripts/cdn-rewrite-map.json`
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
- Maps import specifiers to CDN URLs. During bundling, matching specifiers in source files are rewritten to their CDN equivalents.
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
- "import-specifier": "https://cdn.jsdelivr.net/npm/package-name@<VERSION>/dist/index.bundle.js"
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.11.0+6625dc3
1
+ 0.12.0-pre.1+78f65d1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temir.ra/create-ts-lib",
3
- "version": "0.11.0",
3
+ "version": "0.12.0-pre.1",
4
4
  "description": "A template for a distributable TypeScript library package.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -24,11 +24,11 @@
24
24
  npm install
25
25
  npm update
26
26
 
27
- npm run dev
28
-
29
27
  npm run clean
30
28
  npm run build
31
29
  npm run tests
30
+
31
+ npm run dev
32
32
  ```
33
33
 
34
34
  ## Change Management
@@ -16,7 +16,7 @@
16
16
  "files": [
17
17
  "scripts/buildinfo.ts",
18
18
  "scripts/build-bundle.ts",
19
- "scripts/cdn-rewrite-map.json",
19
+ "scripts/import-map.json",
20
20
  "CHANGELOG.md",
21
21
  "buildinfo.txt",
22
22
  "dist/",
@@ -11,7 +11,7 @@ import {
11
11
  type BuildResult
12
12
  } from 'esbuild';
13
13
 
14
- import CDN_REWRITE_MAP from './cdn-rewrite-map.json';
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 cdnRewrite: EsbuildPlugin = {
126
- name: 'cdn-rewrite',
125
+ const importMap: EsbuildPlugin = {
126
+ name: 'import-map',
127
127
  setup(build: PluginBuild) {
128
128
 
129
- for (const [importSpecifier, urlTemplate] of Object.entries(CDN_REWRITE_MAP) as [string, string][]) {
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(`[cdn-rewrite plugin] '${importSpecifier}' → '${url}'`);
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, cdnRewrite],
160
+ plugins: [esbuildLog, importMap],
161
161
 
162
162
  };
163
163
 
@@ -0,0 +1 @@
1
+ {}
@@ -1 +0,0 @@
1
- {}