react-streaming
Advanced tools
Comparing version 0.2.10 to 0.2.11
@@ -206,3 +206,4 @@ "use strict"; | ||
(0, utils_1.assertUsage)(versionMajor >= 18, `\`react-dom@${server_1.version}\` was loaded, but react-streaming only works with React version 18 or greater.`); | ||
(0, utils_1.assert)(typeof server_1.default.renderToPipeableStream === 'function' || typeof server_1.default.renderToReadableStream === 'function'); | ||
(0, utils_1.assert)(typeof server_1.default.renderToPipeableStream === 'function' || | ||
typeof server_1.default.renderToReadableStream === 'function'); | ||
} | ||
@@ -209,0 +210,0 @@ function assertReactImport(fn, fnName) { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nodeStreamModuleIsAvailable = exports.loadNodeStreamModule = void 0; | ||
const utils_1 = require("../utils"); | ||
async function loadNodeStreamModule() { | ||
@@ -44,7 +22,3 @@ const streamModule = await loadStreamModule(); | ||
function loadStreamModule() { | ||
return loadModule('stream'); | ||
return (0, utils_1.loadModule)('stream'); | ||
} | ||
function loadModule(moduleId) { | ||
// #6 | ||
return Promise.resolve().then(() => __importStar(require(/*webpackIgnore: true*/ moduleId))); | ||
} |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
export declare function isServerSide(): boolean; | ||
@@ -10,1 +11,5 @@ export declare function isClientSide(): boolean; | ||
}): debug.Debugger['log']; | ||
export declare function loadModule(moduleId: string): Promise<Record<string, unknown>>; | ||
declare global { | ||
var __non_webpack_require__: typeof require | undefined; | ||
} |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -6,3 +29,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createDebugger = exports.assertWarning = exports.assertUsage = exports.assert = exports.isClientSide = exports.isServerSide = void 0; | ||
exports.loadModule = exports.createDebugger = exports.assertWarning = exports.assertUsage = exports.assert = exports.isClientSide = exports.isServerSide = void 0; | ||
function isServerSide() { | ||
@@ -74,1 +97,17 @@ return !isClientSide(); | ||
exports.createDebugger = createDebugger; | ||
function loadModule(moduleId) { | ||
// - `eval()` triggers a esbuild warning | ||
// - `new Function()` chokes Vitest/Jest (https://github.com/facebook/jest/issues/9580) | ||
// - Webpack 5 seems to replace any occurence of `require` (e.g. this doesn't work: `const req = new Date().getTime() < 0 ? (0 as never) : require`) | ||
// - Webpack 5 reproduction: https://github.com/brillout/vps-webpack-5-reproduction | ||
// === For `dist/cjs/` === | ||
// https://github.com/webpack/webpack/issues/8826#issuecomment-660594260 | ||
if (typeof __non_webpack_require__ === 'function') { | ||
return __non_webpack_require__(moduleId); | ||
} | ||
// === For `dist/esm/` === | ||
// - https://github.com/webpack/webpack/issues/7644#issuecomment-402123392 | ||
// - This doesn't work for `dist/cjs` because TS transpiles `import()` to `require()` (https://github.com/microsoft/TypeScript/issues/43329) | ||
return Promise.resolve().then(() => __importStar(require(/*webpackIgnore: true*/ moduleId))); | ||
} | ||
exports.loadModule = loadModule; |
@@ -177,3 +177,4 @@ export { renderToStream }; | ||
assertUsage(versionMajor >= 18, `\`react-dom@${reactDomVersion}\` was loaded, but react-streaming only works with React version 18 or greater.`); | ||
assert(typeof ReactDOMServer.renderToPipeableStream === 'function' || typeof ReactDOMServer.renderToReadableStream === 'function'); | ||
assert(typeof ReactDOMServer.renderToPipeableStream === 'function' || | ||
typeof ReactDOMServer.renderToReadableStream === 'function'); | ||
} | ||
@@ -180,0 +181,0 @@ function assertReactImport(fn, fnName) { |
export { loadNodeStreamModule }; | ||
export { nodeStreamModuleIsAvailable }; | ||
import { loadModule } from '../utils'; | ||
async function loadNodeStreamModule() { | ||
@@ -20,5 +21,1 @@ const streamModule = await loadStreamModule(); | ||
} | ||
function loadModule(moduleId) { | ||
// #6 | ||
return import(/*webpackIgnore: true*/ moduleId); | ||
} |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
export declare function isServerSide(): boolean; | ||
@@ -10,1 +11,5 @@ export declare function isClientSide(): boolean; | ||
}): debug.Debugger['log']; | ||
export declare function loadModule(moduleId: string): Promise<Record<string, unknown>>; | ||
declare global { | ||
var __non_webpack_require__: typeof require | undefined; | ||
} |
@@ -61,1 +61,16 @@ export function isServerSide() { | ||
} | ||
export function loadModule(moduleId) { | ||
// - `eval()` triggers a esbuild warning | ||
// - `new Function()` chokes Vitest/Jest (https://github.com/facebook/jest/issues/9580) | ||
// - Webpack 5 seems to replace any occurence of `require` (e.g. this doesn't work: `const req = new Date().getTime() < 0 ? (0 as never) : require`) | ||
// - Webpack 5 reproduction: https://github.com/brillout/vps-webpack-5-reproduction | ||
// === For `dist/cjs/` === | ||
// https://github.com/webpack/webpack/issues/8826#issuecomment-660594260 | ||
if (typeof __non_webpack_require__ === 'function') { | ||
return __non_webpack_require__(moduleId); | ||
} | ||
// === For `dist/esm/` === | ||
// - https://github.com/webpack/webpack/issues/7644#issuecomment-402123392 | ||
// - This doesn't work for `dist/cjs` because TS transpiles `import()` to `require()` (https://github.com/microsoft/TypeScript/issues/43329) | ||
return import(/*webpackIgnore: true*/ moduleId); | ||
} |
{ | ||
"name": "react-streaming", | ||
"description": "React 18 Streaming. Full-fledged & Easy.", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"main": "./dist/cjs/index.js", | ||
@@ -27,3 +27,3 @@ "peerDependencies": { | ||
"build:esm": "tsc --project ./tsconfig.esm.json", | ||
"prepublishOnly": "pnpm run build", | ||
"// prepublishOnly": "pnpm run build", | ||
"clean": "rm -rf dist/" | ||
@@ -30,0 +30,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74290
1549