-
Notifications
You must be signed in to change notification settings - Fork 19
add ability to generate chained sourcemap for precompiled sources #372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
karthik2804
merged 4 commits into
spinframework:main
from
karthik2804:sourcemap_chaining
Aug 25, 2025
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6ebf68f
add ability to generate chained sourcemap for precompiled sources
karthik2804 242d361
Fix sourcemap chaining
karthik2804 a4a8a8b
Make handling of input sourcemaps less flaky
karthik2804 3222e92
add comment explaining inline esbuild plugin
karthik2804 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
getPackagesWithWasiDeps, | ||
processWasiDeps | ||
} from '../../dist/wasiDepsParser.js'; | ||
|
||
export async function SpinEsbuildPlugin() { | ||
const { getWitImports } = await import('../../lib/wit_tools.js'); | ||
|
||
// Step 1: Get WIT imports from dependencies | ||
const wasiDeps = getPackagesWithWasiDeps(process.cwd(), new Set(), true); | ||
const { witPaths, targetWorlds } = processWasiDeps(wasiDeps); | ||
const witImports = getWitImports(witPaths, targetWorlds); | ||
|
||
// Store as a Set for fast lookup | ||
const externals = new Set(witImports); | ||
|
||
return { | ||
name: 'spin-sdk-externals', | ||
setup(build) { | ||
build.onResolve({ filter: /.*/ }, args => { | ||
if (externals.has(args.path)) { | ||
return { path: args.path, external: true }; | ||
} | ||
return null; | ||
}); | ||
} | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// build.mjs | ||
import { build } from 'esbuild'; | ||
import path from 'path'; | ||
import { SpinEsbuildPlugin } from "@spinframework/build-tools/plugins/esbuild/index.js"; | ||
import fs from 'fs'; | ||
|
||
const spinPlugin = await SpinEsbuildPlugin(); | ||
|
||
let SourceMapPlugin = { | ||
name: 'excludeVendorFromSourceMap', | ||
setup(build) { | ||
build.onLoad({ filter: /node_modules/ }, args => { | ||
return { | ||
contents: fs.readFileSync(args.path, 'utf8') | ||
+ '\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==', | ||
loader: 'default', | ||
} | ||
}) | ||
karthik2804 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
} | ||
|
||
await build({ | ||
entryPoints: ['./src/index.ts'], | ||
outfile: './build/bundle.js', | ||
bundle: true, | ||
format: 'esm', | ||
platform: 'node', | ||
sourcemap: true, | ||
minify: false, | ||
plugins: [spinPlugin, SourceMapPlugin], | ||
logLevel: 'error', | ||
loader: { | ||
'.ts': 'ts', | ||
'.tsx': 'tsx', | ||
}, | ||
resolveExtensions: ['.ts', '.tsx', '.js'], | ||
// This prevents sourcemaps from traversing into node_modules | ||
sourceRoot: path.resolve(process.cwd(), 'src'), | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.