Skip to content

Commit

Permalink
Pin react version (close #549)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Mar 26, 2023
1 parent 2fc75ea commit ea32ee2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"./types.d.ts"
],
"jsx": "react-jsx",
"jsxImportSource": "https://esm.sh/react@18.2.0"
"jsxImportSource": "https://esm.sh/v112/react@18.2.0"
},
"importMap": "./import_map.json",
"fmt": {
Expand Down
6 changes: 3 additions & 3 deletions import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"aleph/plugins/solid": "./framework/solid/plugin.ts",
"@unocss/core": "https://esm.sh/v112/@unocss/core@0.50.6",
"@unocss/preset-uno": "https://esm.sh/v112/@unocss/preset-uno@0.50.6",
"react": "https://esm.sh/react@18.2.0",
"react": "https://esm.sh/v112/react@18.2.0",
"react-dom": "https://esm.sh/v112/react-dom@18.2.0",
"react-dom/": "https://esm.sh/v112/react-dom@18.2.0/",
"@mdx-js/react": "https://esm.sh/v112/@mdx-js/react@2.3.0",
"vue": "https://esm.sh/vue@3.2.39",
"vue": "https://esm.sh/v112/vue@3.2.39",
"@vue/server-renderer": "https://esm.sh/v112/@vue/server-renderer@3.2.39",
"solid-js": "https://esm.sh/solid-js@1.6.12",
"solid-js": "https://esm.sh/v112/solid-js@1.6.12",
"solid-js/web": "https://esm.sh/solid-js@1.6.12/web",
"solid-refresh": "https://esm.sh/v112/solid-refresh@0.5.1&deps=solid-js@1.6.12"
}
Expand Down
4 changes: 2 additions & 2 deletions init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default async function init(nameArg?: string, options?: Options) {
Object.assign(importMap.imports, {
"aleph/react": `${alephPkgUri}/framework/react/mod.ts`,
"aleph/plugins/react": `${alephPkgUri}/framework/react/plugin.ts`,
"react": `https://esm.sh/react@${versions.react}`,
"react": `https://esm.sh/v${ESM_VERSION}/react@${versions.react}`,
"react-dom": `https://esm.sh/v${ESM_VERSION}/react-dom@${versions.react}`,
"react-dom/": `https://esm.sh/v${ESM_VERSION}/react-dom@${versions.react}/`,
});
Expand All @@ -223,7 +223,7 @@ export default async function init(nameArg?: string, options?: Options) {
Object.assign(importMap.imports, {
"aleph/vue": `${alephPkgUri}/framework/vue/mod.ts`,
"aleph/plugins/vue": `${alephPkgUri}/framework/vue/plugin.ts`,
"vue": `https://esm.sh/vue@${versions.vue}`,
"vue": `https://esm.sh/v${ESM_VERSION}/vue@${versions.vue}`,
"@vue/server-renderer": `https://esm.sh/v${ESM_VERSION}/@vue/server-renderer@${versions.vue}`,
});
break;
Expand Down
3 changes: 1 addition & 2 deletions plugins/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export class MDXLoader implements ModuleLoader {
const ret = await compile(
{ path: specifier, value: content },
{
jsxImportSource: this.#options.jsxImportSource ?? env.jsxConfig?.jsxImportSource ??
"https://esm.sh/react@18.2.0",
jsxImportSource: this.#options.jsxImportSource ?? env.jsxConfig?.jsxImportSource,
...this.#options,
providerImportSource: this.#options.providerImportSource
? env.importMap?.imports[this.#options.providerImportSource] ?? this.#options.providerImportSource
Expand Down
4 changes: 2 additions & 2 deletions server/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function toResponse(v: unknown, init?: ResponseInit): Response {

/**
* Fix remote url to local path.
* e.g. `https://esm.sh/react@17.0.2?dev` -> `/-/esm.sh/react@17.0.2?dev`
* e.g. `https://esm.sh/react@18.2.0?dev` -> `/-/esm.sh/react@18.2.0?dev`
*/
export function toLocalPath(url: string): string {
if (isLikelyHttpURL(url)) {
Expand All @@ -185,7 +185,7 @@ export function toLocalPath(url: string): string {

/**
* Restore the remote url from local path.
* e.g. `/-/esm.sh/react@17.0.2` -> `https://esm.sh/v112/react@17.0.2`
* e.g. `/-/esm.sh/react@18.2.0` -> `https://esm.sh/v112/react@18.2.0`
*/
export function restoreUrl(pathname: string): string {
let [h, ...rest] = pathname.substring(3).split("/");
Expand Down

0 comments on commit ea32ee2

Please sign in to comment.