Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist.js
dist/
build/
docs/
!templates/**/.vscode/
14 changes: 14 additions & 0 deletions templates/http-js/content/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "starlingmonkey",
"request": "launch",
"name": "Debug StarlingMonkey component",
"component": "${workspaceFolder}/dist/{{ project-name | kebab_case }}.wasm",
"program": "${workspaceFolder}/src/index.js",
"stopOnEntry": false,
"trace": true
}
]
}
12 changes: 12 additions & 0 deletions templates/http-js/content/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"starlingmonkey": {
"componentRuntime": {
"executable": "spin",
"options": [
"up",
"-f",
"${workspaceFolder}",
],
}
}
}
42 changes: 42 additions & 0 deletions templates/http-js/content/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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();

// plugin to handle vendor files in node_modules that may not be bundled.
// Instead of generating a real source map for these files, it appends a minimal
// inline source map pointing to an empty source. This avoids errors and ensures
// source maps exist even for unbundled vendor code.
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',
}
})
},
}

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'],
sourceRoot: path.resolve(process.cwd(), 'src'),
});
5 changes: 2 additions & 3 deletions templates/http-js/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
"description": "{{project-description}}",
"main": "index.js",
"scripts": {
"build": "npx webpack && mkdirp dist && j2w -i build/bundle.js -o dist/{{ project-name | kebab_case }}.wasm",
"build": "node build.mjs && mkdirp dist && j2w -i build/bundle.js -o dist/{{ project-name | kebab_case }}.wasm",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"mkdirp": "^3.0.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
"esbuild": "^0.25.8"
},
"dependencies": {
{%- case http-router -%}
Expand Down
32 changes: 0 additions & 32 deletions templates/http-js/content/webpack.config.js

This file was deleted.

14 changes: 14 additions & 0 deletions templates/http-ts/content/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "starlingmonkey",
"request": "launch",
"name": "Debug StarlingMonkey component",
"component": "${workspaceFolder}/dist/{{ project-name | kebab_case }}.wasm",
"program": "${workspaceFolder}/src/index.ts",
"stopOnEntry": false,
"trace": true
}
]
}
12 changes: 12 additions & 0 deletions templates/http-ts/content/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"starlingmonkey": {
"componentRuntime": {
"executable": "spin",
"options": [
"up",
"-f",
"${workspaceFolder}",
],
}
}
}
42 changes: 42 additions & 0 deletions templates/http-ts/content/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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();

// plugin to handle vendor files in node_modules that may not be bundled.
// Instead of generating a real source map for these files, it appends a minimal
// inline source map pointing to an empty source. This avoids errors and ensures
// source maps exist even for unbundled vendor code.
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',
}
})
},
}

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'],
sourceRoot: path.resolve(process.cwd(), 'src'),
});
5 changes: 2 additions & 3 deletions templates/http-ts/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "{{project-description}}",
"main": "index.js",
"scripts": {
"build": "npx webpack && mkdirp dist && j2w -i build/bundle.js -o dist/{{ project-name | kebab_case }}.wasm",
"build": "node build.mjs && mkdirp dist && j2w -i build/bundle.js -o dist/{{ project-name | kebab_case }}.wasm",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
Expand All @@ -14,8 +14,7 @@
"mkdirp": "^3.0.1",
"ts-loader": "^9.4.1",
"typescript": "^4.8.4",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
"esbuild": "^0.25.8"
},
"dependencies": {
{%- case http-router -%}
Expand Down
44 changes: 0 additions & 44 deletions templates/http-ts/content/webpack.config.js

This file was deleted.

14 changes: 14 additions & 0 deletions test/test-app/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "starlingmonkey",
"request": "launch",
"name": "Debug StarlingMonkey component",
"component": "${workspaceFolder}/dist/test-app.wasm",
"program": "${workspaceFolder}/src/index.ts",
"stopOnEntry": false,
"trace": true
}
]
}
12 changes: 12 additions & 0 deletions test/test-app/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"starlingmonkey": {
"componentRuntime": {
"executable": "spin",
"options": [
"up",
"-f",
"${workspaceFolder}",
],
}
}
}