Node.js requires a custom https-loader: https://nodejs.org/api/esm.html#https-loader
The loader (https-loader.js):
The sample file (sample.js):
export const example = () => ({ foo: "bar" });| FROM node:lts-alpine AS builder | |
| ARG PNPM_HOME="/root/.local/share/pnpm" | |
| ARG PATH="${PATH}:${PNPM_HOME}" | |
| WORKDIR /app | |
| COPY . . | |
| RUN npx --yes pnpm add --global pnpm@latest && \ |
| { | |
| "$schema": "http://json-schema.org/draft-07/schema#", | |
| "title": "WebContainer project configuration", | |
| "description": "https://developer.stackblitz.com/docs/platform/project-config/", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "properties": { | |
| "installDependencies": { | |
| "title": "Install npm dependencies when opening the project.", | |
| "description": "Defaults to true. Set to false to disable.", |
| curl --silent --location \ | |
| --request POST \ | |
| --url 'https://spacex-production.up.railway.app' \ | |
| --header 'Content-Type: application/json' \ | |
| --data '{"query":"query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } }","variable":{}}' |
Node.js requires a custom https-loader: https://nodejs.org/api/esm.html#https-loader
The loader (https-loader.js):
The sample file (sample.js):
export const example = () => ({ foo: "bar" });| <!doctype html> | |
| <html lang='en'> | |
| <head> | |
| <meta charset='UTF-8' /> | |
| <title>_TITLE_</title> | |
| <link rel='stylesheet' type='text/css' href='https://unpkg.com/swagger-ui-dist/swagger-ui.css' /> | |
| <style> | |
| *, | |
| *:before, |
| const promise1 = Promise.resolve(1); | |
| const promise2 = Promise.reject(2); | |
| /** | |
| * Promise.all() example | |
| * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all | |
| */ | |
| Promise.all([promise1, promise2]) | |
| .then((value) => console.log({ value })) | |
| .catch((error) => console.log({ error })); |
| /** | |
| * Wrap any complex and hard to read type with this | |
| * and it'll magically be a lot simpler on hover. | |
| */ | |
| export type Pretty<T> = { [K in keyof T]: T[K] } & {}; |
| { | |
| "$schema": "http://json-schema.org/draft-07/schema#", | |
| "type": "object", | |
| "properties": { | |
| "name": { | |
| "type": "string", | |
| "description": "The name of the project" | |
| }, | |
| "main": { | |
| "type": "string", |
| /** | |
| * @param ms milliseconds to sleep | |
| * @returns void | |
| */ | |
| export function sleep(ms: number): void { | |
| /** | |
| * In some environments such as Cloudflare Workers, Atomics is not defined | |
| * setTimeout is used as a fallback | |
| */ | |
| if (typeof Atomics === 'undefined') { |
| function perf {: | |
| curl --silent \ | |
| --url "$1" \ | |
| --output /dev/null \ | |
| --write-out "\n%{time_total} sec\n%{size_download} bytes\n" | |
| } | |