Skip to content
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

Object prototype may only be an Object or null: undefined #91

Closed
netanel-mce opened this issue Dec 21, 2023 · 2 comments
Closed

Object prototype may only be an Object or null: undefined #91

netanel-mce opened this issue Dec 21, 2023 · 2 comments

Comments

@netanel-mce
Copy link

netanel-mce commented Dec 21, 2023

I use esbuild plugin that used this package to polyfill packges to browser.
I got this Error:

Uncaught TypeError: Object prototype may only be an Object or null: undefined
    at Function.create (<anonymous>)
    at Object.t$2 (chunk-b4205b57.js:3:957)
    at ../../../../node_modules/jws/lib/data-stream.js (data-stream.js:39:6)
    at __require2 (index.js:20:52)
    at ../../../../node_modules/jws/lib/sign-stream.js (sign-stream.js:3:18)
    at __require2 (index.js:20:52)
    at ../../../../node_modules/jws/index.js (index.js:2:18)
    at __require2 (index.js:20:52)
    at ../../../../node_modules/jsonwebtoken/decode.js (decode.js:1:11)
    at __require2 (index.js:20:52)

versions:
@jspm/core@^2.0.1
esbuild-plugin-polyfill-node@^0.3.0
esbuild:@^0.19.10

esbuild.config.ts:

import * as esbuild from "esbuild";
import { polyfillNode } from "esbuild-plugin-polyfill-node/dist";

(async () => {
	const context = await esbuild.context({
		entryPoints: [
			"./lib/index.ts",
			"./config.ts",
		],
		bundle: true,
		outdir: "dist",
		platform: "browser",
		sourcemap: true,
		/**
		 * Minify takes about 3 seconds
		 */
		minify: false,
		plugins: [
			polyfillNode({
				polyfills: {
					crypto: true,
					path: true,
					http: true,
					https: true,
					os: true,
					util: true,
					stream: true,
					zlib: true,
					assert: true,
					fs: true,
					process: true,
					buffer: true,
				},
				globals: {
					process: true,
					buffer: true,
					global: true,
				},
			}),
		],
	});

	await context.watch();
	await context.serve({ port: 8080, servedir: "./dist" });
})();
@netanel-mce
Copy link
Author

netanel-mce commented Dec 22, 2023

Minimal steps to reproduce:

Files tree: (you can use file attachment)

-package.json
-index.html
-index.js
-esbuild.config.js

Files content:

package.json:

{
  "name": "jspm-bug-reproduce",
  "version": "1.0.0",
  "scripts": {
    "build": "node esbuild.config"
  },
  "dependencies": {
    "jsonwebtoken": "^9.0.2"
  },
  "devDependencies": {
    "esbuild": "^0.19.10",
    "esbuild-plugin-polyfill-node": "^0.3.0"
  }
}

index.html:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <title>jspm-bug-reproduce</title>
</head>
<body>
  <script src="./bundle.js"></script>
</body>
</html>

index.js:

const { decode } = require("jsonwebtoken"); //! You can import anything, the error will occur anyway

console.log(decode);

esbuild.config.js:

const esbuild = require("esbuild");
const { polyfillNode } = require("esbuild-plugin-polyfill-node");

(async () => {
  await esbuild.build({
    entryPoints: ["./index.js"],
    bundle: true,
    outfile: "./bundle.js",
    platform: "browser",
    plugins: [
      polyfillNode(),
    ],
  });
})();

Run:

  • npm i
  • npm run build
  • open the index.html file by browser
  • see error in browser console

jspm-bug-reproduce.zip

@netanel-mce netanel-mce closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2023
@netanel-mce
Copy link
Author

Duplicate auth0/node-jws#101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant