@vscode/esbuild-plugin-esm-url 1.0.1-0
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/README.md +65 -0
- package/dist/cjs/index.d.ts +18 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +201 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.d.ts +18 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +178 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @vscode/esbuild-plugin-esm-url
|
|
2
|
+
|
|
3
|
+
An esbuild plugin that transforms `new URL('./worker.js?esm', import.meta.url)` patterns into bundled worker entry points.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vscode/esbuild-plugin-esm-url esbuild
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import * as esbuild from 'esbuild';
|
|
15
|
+
import { esmUrlPlugin } from '@vscode/esbuild-plugin-esm-url';
|
|
16
|
+
|
|
17
|
+
await esbuild.build({
|
|
18
|
+
entryPoints: ['src/index.js'],
|
|
19
|
+
bundle: true,
|
|
20
|
+
outdir: 'dist',
|
|
21
|
+
format: 'esm',
|
|
22
|
+
plugins: [esmUrlPlugin()],
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## How it works
|
|
27
|
+
|
|
28
|
+
The plugin scans for `new URL('./path/to/worker.js?esm', import.meta.url)` patterns and:
|
|
29
|
+
|
|
30
|
+
1. Extracts the worker file path
|
|
31
|
+
2. Builds the worker as a separate ESM entry point
|
|
32
|
+
3. Replaces the URL pattern with a reference to the bundled worker
|
|
33
|
+
|
|
34
|
+
## Options
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
interface EsmUrlPluginOptions {
|
|
38
|
+
/**
|
|
39
|
+
* When true, strips the ?esm query parameter from output URLs.
|
|
40
|
+
* When false (default), preserves ?esm for re-bundling scenarios.
|
|
41
|
+
*/
|
|
42
|
+
stripEsmQuery?: boolean;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Custom function to generate output file names for worker/module files.
|
|
46
|
+
* Receives the file path and suggested name, should return the desired name (without extension).
|
|
47
|
+
*/
|
|
48
|
+
getOutputFileName?: (info: { filePath: string; suggestedName: string }) => string;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Example with options
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
import { esmUrlPlugin } from '@vscode/esbuild-plugin-esm-url';
|
|
56
|
+
|
|
57
|
+
esmUrlPlugin({
|
|
58
|
+
stripEsmQuery: true,
|
|
59
|
+
getOutputFileName: ({ suggestedName }) => `worker-${suggestedName}`,
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from 'esbuild';
|
|
2
|
+
import { type OutputFileNameInfo } from '@vscode/esm-url-plugin-common';
|
|
3
|
+
export type { OutputFileNameInfo };
|
|
4
|
+
export interface EsmUrlPluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* When true, strips the ?esm query parameter from output URLs.
|
|
7
|
+
* When false (default), preserves ?esm for re-bundling scenarios.
|
|
8
|
+
*/
|
|
9
|
+
stripEsmQuery?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Custom function to generate output file names for worker/module files.
|
|
12
|
+
* Receives the file path and suggested name, should return the desired name (without extension).
|
|
13
|
+
*/
|
|
14
|
+
getOutputFileName?: (info: OutputFileNameInfo) => string;
|
|
15
|
+
}
|
|
16
|
+
export declare function esmUrlPlugin(options?: EsmUrlPluginOptions): Plugin;
|
|
17
|
+
export { esmUrlPlugin as esbuildEsmUrlPlugin };
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAKL,KAAK,kBAAkB,EAExB,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,MAAM,CAAC;CAC1D;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAwItE;AAED,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
24
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Strips only the 'esm' parameter from a query string, preserving other parameters.
|
|
28
|
+
* @param queryString The full query string (e.g., '?esm&foo=true' or '?foo=true&esm&bar=1')
|
|
29
|
+
* @returns The query string without the 'esm' parameter, or empty string if no params remain
|
|
30
|
+
*/
|
|
31
|
+
function stripEsmFromQuery(queryString) {
|
|
32
|
+
if (!queryString || queryString === '?esm')
|
|
33
|
+
return '';
|
|
34
|
+
const params = new URLSearchParams(queryString.startsWith('?') ? queryString.slice(1) : queryString);
|
|
35
|
+
params.delete('esm');
|
|
36
|
+
const result = params.toString();
|
|
37
|
+
return result ? '?' + result : '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Generates a bundle entry name from a file path relative to a context directory.
|
|
42
|
+
*
|
|
43
|
+
* @param absolutePath - Absolute path to the worker/module file
|
|
44
|
+
* @param contextDir - Context directory to compute relative path from
|
|
45
|
+
* @returns A sanitized entry name suitable for use as a bundle filename
|
|
46
|
+
*/
|
|
47
|
+
function generateEntryName(absolutePath, contextDir) {
|
|
48
|
+
let relativePath = path__namespace.relative(contextDir, absolutePath);
|
|
49
|
+
// Handle cross-drive paths on Windows: path.relative() returns absolute path
|
|
50
|
+
// when paths are on different drives (e.g., C: vs D:)
|
|
51
|
+
if (path__namespace.isAbsolute(relativePath)) {
|
|
52
|
+
// Strip drive letter (e.g., "D:" or "D:\") on Windows
|
|
53
|
+
relativePath = relativePath.replace(/^[a-zA-Z]:[\\\/]?/, '');
|
|
54
|
+
}
|
|
55
|
+
return relativePath
|
|
56
|
+
.replace(/\.[^/.]+$/, '') // Remove extension
|
|
57
|
+
.replace(/\\/g, '/') // Normalize Windows slashes
|
|
58
|
+
.replace(/^(\.\.\/)+/g, '') // Remove leading ../ segments
|
|
59
|
+
.replace(/^\.\//, '') // Remove leading ./
|
|
60
|
+
.replace(/\//g, '-') // Replace slashes with dashes
|
|
61
|
+
.replace(/^\.+/, ''); // Remove any remaining leading dots
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const ESM_QUERY = '?esm';
|
|
65
|
+
/**
|
|
66
|
+
* Finds `new URL('...?esm...', import.meta.url)` patterns using regex.
|
|
67
|
+
* May have false positives in comments or strings, but this is rare in practice.
|
|
68
|
+
*/
|
|
69
|
+
function findMatches(code) {
|
|
70
|
+
const urlPattern = /new\s+URL\s*\(\s*(['"`])([^'"`]+\?esm[^'"`]*)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
71
|
+
const matches = [];
|
|
72
|
+
let match;
|
|
73
|
+
while ((match = urlPattern.exec(code)) !== null) {
|
|
74
|
+
const urlString = match[2];
|
|
75
|
+
if (urlString.includes(ESM_QUERY)) {
|
|
76
|
+
matches.push({
|
|
77
|
+
urlString,
|
|
78
|
+
start: match.index,
|
|
79
|
+
end: match.index + match[0].length,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return matches;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function esmUrlPlugin(options = {}) {
|
|
87
|
+
const { stripEsmQuery = false, getOutputFileName } = options;
|
|
88
|
+
return {
|
|
89
|
+
name: 'esm-url-plugin',
|
|
90
|
+
setup(build) {
|
|
91
|
+
const workerEntries = new Map(); // absolutePath -> entryName
|
|
92
|
+
const workerBuilds = new Map(); // entryName -> output filename
|
|
93
|
+
const usedEntryNames = new Set();
|
|
94
|
+
// Get the output directory from build options
|
|
95
|
+
const outdir = build.initialOptions.outdir || 'dist';
|
|
96
|
+
const absOutdir = path__namespace.resolve(process.cwd(), outdir);
|
|
97
|
+
// Track first entry point directory as the "context" for relative paths
|
|
98
|
+
let contextDir;
|
|
99
|
+
build.onLoad({ filter: /\.(c|m)?[jt]sx?$/ }, async (args) => {
|
|
100
|
+
// Set context directory based on first loaded file (usually the entry point)
|
|
101
|
+
if (!contextDir) {
|
|
102
|
+
contextDir = path__namespace.dirname(args.path);
|
|
103
|
+
}
|
|
104
|
+
const contents = await fs__namespace.promises.readFile(args.path, 'utf8');
|
|
105
|
+
// Quick check: skip files that don't contain ?esm
|
|
106
|
+
if (!contents.includes(ESM_QUERY)) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const rawMatches = findMatches(contents);
|
|
110
|
+
if (rawMatches.length === 0) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
// Convert raw matches to full matches with resolved paths
|
|
114
|
+
const errors = [];
|
|
115
|
+
const matches = [];
|
|
116
|
+
for (const raw of rawMatches) {
|
|
117
|
+
const [workerPath, ...queryParts] = raw.urlString.split('?');
|
|
118
|
+
const originalQuery = queryParts.length > 0 ? '?' + queryParts.join('?') : '';
|
|
119
|
+
const importerDir = path__namespace.dirname(args.path);
|
|
120
|
+
const absolutePath = path__namespace.resolve(importerDir, workerPath);
|
|
121
|
+
// Check that the file exists
|
|
122
|
+
if (!fs__namespace.existsSync(absolutePath)) {
|
|
123
|
+
const lines = contents.slice(0, raw.start).split('\n');
|
|
124
|
+
const line = lines.length;
|
|
125
|
+
const column = lines[lines.length - 1].length;
|
|
126
|
+
errors.push({
|
|
127
|
+
text: `File not found: '${workerPath}' resolved to '${absolutePath}'. Check that the path in new URL('${raw.urlString}', import.meta.url) points to an existing file.`,
|
|
128
|
+
location: { file: args.path, line, column }
|
|
129
|
+
});
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
let entryName = generateEntryName(absolutePath, contextDir);
|
|
133
|
+
// Handle duplicate names by adding a suffix
|
|
134
|
+
let finalEntryName = entryName;
|
|
135
|
+
let counter = 1;
|
|
136
|
+
while (usedEntryNames.has(finalEntryName) && workerEntries.get(absolutePath) !== finalEntryName) {
|
|
137
|
+
finalEntryName = `${entryName}-${counter++}`;
|
|
138
|
+
}
|
|
139
|
+
// Apply custom output file name if provided
|
|
140
|
+
if (getOutputFileName) {
|
|
141
|
+
finalEntryName = getOutputFileName({ filePath: absolutePath, suggestedName: finalEntryName });
|
|
142
|
+
}
|
|
143
|
+
usedEntryNames.add(finalEntryName);
|
|
144
|
+
workerEntries.set(absolutePath, finalEntryName);
|
|
145
|
+
matches.push({
|
|
146
|
+
filePath: absolutePath,
|
|
147
|
+
entryName: finalEntryName,
|
|
148
|
+
originalQuery,
|
|
149
|
+
start: raw.start,
|
|
150
|
+
end: raw.end,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
// Return errors if any files were not found
|
|
154
|
+
if (errors.length > 0) {
|
|
155
|
+
return { errors };
|
|
156
|
+
}
|
|
157
|
+
// Replace matches in reverse order to preserve positions
|
|
158
|
+
let newContents = contents;
|
|
159
|
+
for (const m of matches.slice().reverse()) {
|
|
160
|
+
const suffix = stripEsmQuery ? stripEsmFromQuery(m.originalQuery) : m.originalQuery;
|
|
161
|
+
const replacement = `new URL('./${m.entryName}.js${suffix}', import.meta.url)`;
|
|
162
|
+
newContents = newContents.slice(0, m.start) + replacement + newContents.slice(m.end);
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
contents: newContents,
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
// Build workers at the end
|
|
169
|
+
build.onEnd(async (result) => {
|
|
170
|
+
if (result.errors.length > 0) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Import esbuild dynamically to build workers
|
|
174
|
+
const esbuild = await import('esbuild');
|
|
175
|
+
// Build each worker as a separate entry point
|
|
176
|
+
for (const [absolutePath, entryName] of workerEntries) {
|
|
177
|
+
const workerOutfile = path__namespace.join(absOutdir, `${entryName}.js`);
|
|
178
|
+
await esbuild.build({
|
|
179
|
+
entryPoints: [absolutePath],
|
|
180
|
+
bundle: true,
|
|
181
|
+
format: 'esm',
|
|
182
|
+
outfile: workerOutfile,
|
|
183
|
+
// Don't apply the plugin to worker builds to avoid infinite recursion
|
|
184
|
+
plugins: [],
|
|
185
|
+
// Use same settings as parent build where applicable
|
|
186
|
+
minify: build.initialOptions.minify,
|
|
187
|
+
sourcemap: build.initialOptions.sourcemap,
|
|
188
|
+
target: build.initialOptions.target,
|
|
189
|
+
define: build.initialOptions.define,
|
|
190
|
+
external: build.initialOptions.external,
|
|
191
|
+
});
|
|
192
|
+
workerBuilds.set(entryName, `${entryName}.js`);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
exports.esbuildEsmUrlPlugin = esmUrlPlugin;
|
|
200
|
+
exports.esmUrlPlugin = esmUrlPlugin;
|
|
201
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../common/dist/esm/index.js","../../../src/index.ts"],"sourcesContent":["import * as path from 'path';\n\n/**\n * Strips only the 'esm' parameter from a query string, preserving other parameters.\n * @param queryString The full query string (e.g., '?esm&foo=true' or '?foo=true&esm&bar=1')\n * @returns The query string without the 'esm' parameter, or empty string if no params remain\n */\nfunction stripEsmFromQuery(queryString) {\n if (!queryString || queryString === '?esm')\n return '';\n const params = new URLSearchParams(queryString.startsWith('?') ? queryString.slice(1) : queryString);\n params.delete('esm');\n const result = params.toString();\n return result ? '?' + result : '';\n}\n\n/**\n * Generates a bundle entry name from a file path relative to a context directory.\n *\n * @param absolutePath - Absolute path to the worker/module file\n * @param contextDir - Context directory to compute relative path from\n * @returns A sanitized entry name suitable for use as a bundle filename\n */\nfunction generateEntryName(absolutePath, contextDir) {\n let relativePath = path.relative(contextDir, absolutePath);\n // Handle cross-drive paths on Windows: path.relative() returns absolute path\n // when paths are on different drives (e.g., C: vs D:)\n if (path.isAbsolute(relativePath)) {\n // Strip drive letter (e.g., \"D:\" or \"D:\\\") on Windows\n relativePath = relativePath.replace(/^[a-zA-Z]:[\\\\\\/]?/, '');\n }\n return relativePath\n .replace(/\\.[^/.]+$/, '') // Remove extension\n .replace(/\\\\/g, '/') // Normalize Windows slashes\n .replace(/^(\\.\\.\\/)+/g, '') // Remove leading ../ segments\n .replace(/^\\.\\//, '') // Remove leading ./\n .replace(/\\//g, '-') // Replace slashes with dashes\n .replace(/^\\.+/, ''); // Remove any remaining leading dots\n}\n\nconst ESM_QUERY = '?esm';\n/**\n * Finds `new URL('...?esm...', import.meta.url)` patterns using regex.\n * May have false positives in comments or strings, but this is rare in practice.\n */\nfunction findMatches(code) {\n const urlPattern = /new\\s+URL\\s*\\(\\s*(['\"`])([^'\"`]+\\?esm[^'\"`]*)\\1\\s*,\\s*import\\.meta\\.url\\s*\\)/g;\n const matches = [];\n let match;\n while ((match = urlPattern.exec(code)) !== null) {\n const urlString = match[2];\n if (urlString.includes(ESM_QUERY)) {\n matches.push({\n urlString,\n start: match.index,\n end: match.index + match[0].length,\n });\n }\n }\n return matches;\n}\n\nexport { ESM_QUERY, findMatches, generateEntryName, stripEsmFromQuery };\n//# sourceMappingURL=index.js.map\n",null],"names":["path","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,WAAW,EAAE;AACxC,IAAI,IAAI,CAAC,WAAW,IAAI,WAAW,KAAK,MAAM;AAC9C,QAAQ,OAAO,EAAE;AACjB,IAAI,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;AACxG,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;AACxB,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE;AACpC,IAAI,OAAO,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,EAAE;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,YAAY,EAAE,UAAU,EAAE;AACrD,IAAI,IAAI,YAAY,GAAGA,eAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC;AAC9D;AACA;AACA,IAAI,IAAIA,eAA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gBAGvC,KAAK,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,aAAa,EAAE;AACrD,oBAAA,MAAM,aAAa,GAAGD,eAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAA,EAAG,SAAS,CAAA,GAAA,CAAK,CAAC;oBAE7D,MAAM,OAAO,CAAC,KAAK,CAAC;wBAClB,WAAW,EAAE,CAAC,YAAY,CAAC;AAC3B,wBAAA,MAAM,EAAE,IAAI;AACZ,wBAAA,MAAM,EAAE,KAAK;AACb,wBAAA,OAAO,EAAE,aAAa;;AAEtB,wBAAA,OAAO,EAAE,EAAE;;AAEX,wBAAA,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM;AACnC,wBAAA,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,SAAS;AACzC,wBAAA,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM;AACnC,wBAAA,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM;AACnC,wBAAA,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ;AACxC,qBAAA,CAAC;oBAEF,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,CAAA,EAAG,SAAS,CAAA,GAAA,CAAK,CAAC;gBAChD;AACF,YAAA,CAAC,CAAC;QACJ,CAAC;KACF;AACH;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from 'esbuild';
|
|
2
|
+
import { type OutputFileNameInfo } from '@vscode/esm-url-plugin-common';
|
|
3
|
+
export type { OutputFileNameInfo };
|
|
4
|
+
export interface EsmUrlPluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* When true, strips the ?esm query parameter from output URLs.
|
|
7
|
+
* When false (default), preserves ?esm for re-bundling scenarios.
|
|
8
|
+
*/
|
|
9
|
+
stripEsmQuery?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Custom function to generate output file names for worker/module files.
|
|
12
|
+
* Receives the file path and suggested name, should return the desired name (without extension).
|
|
13
|
+
*/
|
|
14
|
+
getOutputFileName?: (info: OutputFileNameInfo) => string;
|
|
15
|
+
}
|
|
16
|
+
export declare function esmUrlPlugin(options?: EsmUrlPluginOptions): Plugin;
|
|
17
|
+
export { esmUrlPlugin as esbuildEsmUrlPlugin };
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAKL,KAAK,kBAAkB,EAExB,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,MAAM,CAAC;CAC1D;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAwItE;AAED,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Strips only the 'esm' parameter from a query string, preserving other parameters.
|
|
6
|
+
* @param queryString The full query string (e.g., '?esm&foo=true' or '?foo=true&esm&bar=1')
|
|
7
|
+
* @returns The query string without the 'esm' parameter, or empty string if no params remain
|
|
8
|
+
*/
|
|
9
|
+
function stripEsmFromQuery(queryString) {
|
|
10
|
+
if (!queryString || queryString === '?esm')
|
|
11
|
+
return '';
|
|
12
|
+
const params = new URLSearchParams(queryString.startsWith('?') ? queryString.slice(1) : queryString);
|
|
13
|
+
params.delete('esm');
|
|
14
|
+
const result = params.toString();
|
|
15
|
+
return result ? '?' + result : '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generates a bundle entry name from a file path relative to a context directory.
|
|
20
|
+
*
|
|
21
|
+
* @param absolutePath - Absolute path to the worker/module file
|
|
22
|
+
* @param contextDir - Context directory to compute relative path from
|
|
23
|
+
* @returns A sanitized entry name suitable for use as a bundle filename
|
|
24
|
+
*/
|
|
25
|
+
function generateEntryName(absolutePath, contextDir) {
|
|
26
|
+
let relativePath = path.relative(contextDir, absolutePath);
|
|
27
|
+
// Handle cross-drive paths on Windows: path.relative() returns absolute path
|
|
28
|
+
// when paths are on different drives (e.g., C: vs D:)
|
|
29
|
+
if (path.isAbsolute(relativePath)) {
|
|
30
|
+
// Strip drive letter (e.g., "D:" or "D:\") on Windows
|
|
31
|
+
relativePath = relativePath.replace(/^[a-zA-Z]:[\\\/]?/, '');
|
|
32
|
+
}
|
|
33
|
+
return relativePath
|
|
34
|
+
.replace(/\.[^/.]+$/, '') // Remove extension
|
|
35
|
+
.replace(/\\/g, '/') // Normalize Windows slashes
|
|
36
|
+
.replace(/^(\.\.\/)+/g, '') // Remove leading ../ segments
|
|
37
|
+
.replace(/^\.\//, '') // Remove leading ./
|
|
38
|
+
.replace(/\//g, '-') // Replace slashes with dashes
|
|
39
|
+
.replace(/^\.+/, ''); // Remove any remaining leading dots
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const ESM_QUERY = '?esm';
|
|
43
|
+
/**
|
|
44
|
+
* Finds `new URL('...?esm...', import.meta.url)` patterns using regex.
|
|
45
|
+
* May have false positives in comments or strings, but this is rare in practice.
|
|
46
|
+
*/
|
|
47
|
+
function findMatches(code) {
|
|
48
|
+
const urlPattern = /new\s+URL\s*\(\s*(['"`])([^'"`]+\?esm[^'"`]*)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
49
|
+
const matches = [];
|
|
50
|
+
let match;
|
|
51
|
+
while ((match = urlPattern.exec(code)) !== null) {
|
|
52
|
+
const urlString = match[2];
|
|
53
|
+
if (urlString.includes(ESM_QUERY)) {
|
|
54
|
+
matches.push({
|
|
55
|
+
urlString,
|
|
56
|
+
start: match.index,
|
|
57
|
+
end: match.index + match[0].length,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return matches;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function esmUrlPlugin(options = {}) {
|
|
65
|
+
const { stripEsmQuery = false, getOutputFileName } = options;
|
|
66
|
+
return {
|
|
67
|
+
name: 'esm-url-plugin',
|
|
68
|
+
setup(build) {
|
|
69
|
+
const workerEntries = new Map(); // absolutePath -> entryName
|
|
70
|
+
const workerBuilds = new Map(); // entryName -> output filename
|
|
71
|
+
const usedEntryNames = new Set();
|
|
72
|
+
// Get the output directory from build options
|
|
73
|
+
const outdir = build.initialOptions.outdir || 'dist';
|
|
74
|
+
const absOutdir = path.resolve(process.cwd(), outdir);
|
|
75
|
+
// Track first entry point directory as the "context" for relative paths
|
|
76
|
+
let contextDir;
|
|
77
|
+
build.onLoad({ filter: /\.(c|m)?[jt]sx?$/ }, async (args) => {
|
|
78
|
+
// Set context directory based on first loaded file (usually the entry point)
|
|
79
|
+
if (!contextDir) {
|
|
80
|
+
contextDir = path.dirname(args.path);
|
|
81
|
+
}
|
|
82
|
+
const contents = await fs.promises.readFile(args.path, 'utf8');
|
|
83
|
+
// Quick check: skip files that don't contain ?esm
|
|
84
|
+
if (!contents.includes(ESM_QUERY)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const rawMatches = findMatches(contents);
|
|
88
|
+
if (rawMatches.length === 0) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
// Convert raw matches to full matches with resolved paths
|
|
92
|
+
const errors = [];
|
|
93
|
+
const matches = [];
|
|
94
|
+
for (const raw of rawMatches) {
|
|
95
|
+
const [workerPath, ...queryParts] = raw.urlString.split('?');
|
|
96
|
+
const originalQuery = queryParts.length > 0 ? '?' + queryParts.join('?') : '';
|
|
97
|
+
const importerDir = path.dirname(args.path);
|
|
98
|
+
const absolutePath = path.resolve(importerDir, workerPath);
|
|
99
|
+
// Check that the file exists
|
|
100
|
+
if (!fs.existsSync(absolutePath)) {
|
|
101
|
+
const lines = contents.slice(0, raw.start).split('\n');
|
|
102
|
+
const line = lines.length;
|
|
103
|
+
const column = lines[lines.length - 1].length;
|
|
104
|
+
errors.push({
|
|
105
|
+
text: `File not found: '${workerPath}' resolved to '${absolutePath}'. Check that the path in new URL('${raw.urlString}', import.meta.url) points to an existing file.`,
|
|
106
|
+
location: { file: args.path, line, column }
|
|
107
|
+
});
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
let entryName = generateEntryName(absolutePath, contextDir);
|
|
111
|
+
// Handle duplicate names by adding a suffix
|
|
112
|
+
let finalEntryName = entryName;
|
|
113
|
+
let counter = 1;
|
|
114
|
+
while (usedEntryNames.has(finalEntryName) && workerEntries.get(absolutePath) !== finalEntryName) {
|
|
115
|
+
finalEntryName = `${entryName}-${counter++}`;
|
|
116
|
+
}
|
|
117
|
+
// Apply custom output file name if provided
|
|
118
|
+
if (getOutputFileName) {
|
|
119
|
+
finalEntryName = getOutputFileName({ filePath: absolutePath, suggestedName: finalEntryName });
|
|
120
|
+
}
|
|
121
|
+
usedEntryNames.add(finalEntryName);
|
|
122
|
+
workerEntries.set(absolutePath, finalEntryName);
|
|
123
|
+
matches.push({
|
|
124
|
+
filePath: absolutePath,
|
|
125
|
+
entryName: finalEntryName,
|
|
126
|
+
originalQuery,
|
|
127
|
+
start: raw.start,
|
|
128
|
+
end: raw.end,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// Return errors if any files were not found
|
|
132
|
+
if (errors.length > 0) {
|
|
133
|
+
return { errors };
|
|
134
|
+
}
|
|
135
|
+
// Replace matches in reverse order to preserve positions
|
|
136
|
+
let newContents = contents;
|
|
137
|
+
for (const m of matches.slice().reverse()) {
|
|
138
|
+
const suffix = stripEsmQuery ? stripEsmFromQuery(m.originalQuery) : m.originalQuery;
|
|
139
|
+
const replacement = `new URL('./${m.entryName}.js${suffix}', import.meta.url)`;
|
|
140
|
+
newContents = newContents.slice(0, m.start) + replacement + newContents.slice(m.end);
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
contents: newContents,
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
// Build workers at the end
|
|
147
|
+
build.onEnd(async (result) => {
|
|
148
|
+
if (result.errors.length > 0) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Import esbuild dynamically to build workers
|
|
152
|
+
const esbuild = await import('esbuild');
|
|
153
|
+
// Build each worker as a separate entry point
|
|
154
|
+
for (const [absolutePath, entryName] of workerEntries) {
|
|
155
|
+
const workerOutfile = path.join(absOutdir, `${entryName}.js`);
|
|
156
|
+
await esbuild.build({
|
|
157
|
+
entryPoints: [absolutePath],
|
|
158
|
+
bundle: true,
|
|
159
|
+
format: 'esm',
|
|
160
|
+
outfile: workerOutfile,
|
|
161
|
+
// Don't apply the plugin to worker builds to avoid infinite recursion
|
|
162
|
+
plugins: [],
|
|
163
|
+
// Use same settings as parent build where applicable
|
|
164
|
+
minify: build.initialOptions.minify,
|
|
165
|
+
sourcemap: build.initialOptions.sourcemap,
|
|
166
|
+
target: build.initialOptions.target,
|
|
167
|
+
define: build.initialOptions.define,
|
|
168
|
+
external: build.initialOptions.external,
|
|
169
|
+
});
|
|
170
|
+
workerBuilds.set(entryName, `${entryName}.js`);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export { esmUrlPlugin as esbuildEsmUrlPlugin, esmUrlPlugin };
|
|
178
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../common/dist/esm/index.js","../../../src/index.ts"],"sourcesContent":["import * as path from 'path';\n\n/**\n * Strips only the 'esm' parameter from a query string, preserving other parameters.\n * @param queryString The full query string (e.g., '?esm&foo=true' or '?foo=true&esm&bar=1')\n * @returns The query string without the 'esm' parameter, or empty string if no params remain\n */\nfunction stripEsmFromQuery(queryString) {\n if (!queryString || queryString === '?esm')\n return '';\n const params = new URLSearchParams(queryString.startsWith('?') ? queryString.slice(1) : queryString);\n params.delete('esm');\n const result = params.toString();\n return result ? '?' + result : '';\n}\n\n/**\n * Generates a bundle entry name from a file path relative to a context directory.\n *\n * @param absolutePath - Absolute path to the worker/module file\n * @param contextDir - Context directory to compute relative path from\n * @returns A sanitized entry name suitable for use as a bundle filename\n */\nfunction generateEntryName(absolutePath, contextDir) {\n let relativePath = path.relative(contextDir, absolutePath);\n // Handle cross-drive paths on Windows: path.relative() returns absolute path\n // when paths are on different drives (e.g., C: vs D:)\n if (path.isAbsolute(relativePath)) {\n // Strip drive letter (e.g., \"D:\" or \"D:\\\") on Windows\n relativePath = relativePath.replace(/^[a-zA-Z]:[\\\\\\/]?/, '');\n }\n return relativePath\n .replace(/\\.[^/.]+$/, '') // Remove extension\n .replace(/\\\\/g, '/') // Normalize Windows slashes\n .replace(/^(\\.\\.\\/)+/g, '') // Remove leading ../ segments\n .replace(/^\\.\\//, '') // Remove leading ./\n .replace(/\\//g, '-') // Replace slashes with dashes\n .replace(/^\\.+/, ''); // Remove any remaining leading dots\n}\n\nconst ESM_QUERY = '?esm';\n/**\n * Finds `new URL('...?esm...', import.meta.url)` patterns using regex.\n * May have false positives in comments or strings, but this is rare in practice.\n */\nfunction findMatches(code) {\n const urlPattern = /new\\s+URL\\s*\\(\\s*(['\"`])([^'\"`]+\\?esm[^'\"`]*)\\1\\s*,\\s*import\\.meta\\.url\\s*\\)/g;\n const matches = [];\n let match;\n while ((match = urlPattern.exec(code)) !== null) {\n const urlString = match[2];\n if (urlString.includes(ESM_QUERY)) {\n matches.push({\n urlString,\n start: match.index,\n end: match.index + match[0].length,\n });\n }\n }\n return matches;\n}\n\nexport { ESM_QUERY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,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM;AACnC,wBAAA,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM;AACnC,wBAAA,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ;AACxC,qBAAA,CAAC;oBAEF,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,CAAA,EAAG,SAAS,CAAA,GAAA,CAAK,CAAC;gBAChD;AACF,YAAA,CAAC,CAAC;QACJ,CAAC;KACF;AACH;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vscode/esbuild-plugin-esm-url",
|
|
3
|
+
"version": "1.0.1-0",
|
|
4
|
+
"description": "esbuild plugin for handling ?esm URL imports",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"types": "./dist/cjs/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/esm/index.d.ts",
|
|
12
|
+
"default": "./dist/esm/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/cjs/index.d.ts",
|
|
16
|
+
"default": "./dist/cjs/index.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "rollup -c rollup.config.mjs",
|
|
25
|
+
"clean": "rimraf dist"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@vscode/esm-url-plugin-common": "*",
|
|
29
|
+
"rollup": "^4.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"esbuild": "^0.17.0 || ^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0 || ^0.26.0 || ^0.27.0"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT"
|
|
35
|
+
}
|