Skip to content

Commit

Permalink
use 'fetch' by default on browser env. force XHR for Cocos Creator. b…
Browse files Browse the repository at this point in the history
…ump 0.15.10
  • Loading branch information
endel committed Jul 6, 2023
1 parent 732eb07 commit 5f39ab6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "colyseus.js",
"version": "0.15.9",
"version": "0.15.10",
"description": "Colyseus Multiplayer SDK for JavaScript/TypeScript",
"author": "Endel Dreyer",
"license": "MIT",
Expand All @@ -12,7 +12,7 @@
"build-zip-dist": "zip --junk-paths colyseus-js-client dist/colyseus.*",
"build-all": "tsc && npm run build && npm run build-dist-dts && npm run copy-cocos-creator-files && npm run copy-construct3-files",
"copy-construct3-files": "cp dist/colyseus.js ../colyseus-construct3/plugin/colyseus.js",
"copy-cocos-creator-files": "cp dist/colyseus.js cocos-creator-3-extension/colyseus-sdk/runtime && cp dist/colyseus.d.ts cocos-creator-3-extension/colyseus-sdk/runtime",
"copy-cocos-creator-files": "cp dist/colyseus-cocos-creator.js cocos-creator-3-extension/colyseus-sdk/runtime/colyseus.js && cp dist/colyseus.d.ts cocos-creator-3-extension/colyseus-sdk/runtime",
"watch": "tsc -w",
"tslint": "tslint --project .",
"prepublishOnly": "tsc && npm run build"
Expand All @@ -36,8 +36,7 @@
"require": "./build/cjs/index.js",
"types": "./lib/index.d.ts"
},
"./package.json": "./package.json",
"./decentraland": "./dist/colyseus-decentraland.js"
"./package.json": "./package.json"
},
"decentralandLibrary": {
"main": "./dist/colyseus-decentraland.js",
Expand Down
13 changes: 6 additions & 7 deletions rollup.config.js
Expand Up @@ -53,8 +53,8 @@ export default [
typescript({ tsconfig: './tsconfig/tsconfig.cjs.json' }),
alias({
entries: [
// httpie: force XHR implementation on browser/UMD environment
{ find: 'httpie', replacement: './node_modules/httpie/xhr/index.js' },
// httpie: force `fetch` for web environments
{ find: 'httpie', replacement: './node_modules/httpie/fetch/index.js' },

// ws: force browser.js version.
{ find: 'ws', replacement: './node_modules/ws/browser.js' },
Expand All @@ -66,20 +66,19 @@ export default [
commonjs(),
nodeResolve({ browser: true }), // "browser" seems to have no effect here. (why??)
],

},

// Decentraland SDK (same as browser/embedded, but use FETCH instead of XHR)
// Cocos Creator SDK (same as browser/embedded, but use XHR instead of fetch)
{
preserveModules: false,
input: ['src/index.ts'],
output: [
{
banner: bannerStatic,
banner: `// THIS VERSION USES "XMLHttpRequest" INSTEAD OF "fetch" FOR COMPATIBILITY WITH COCOS CREATOR\n${bannerStatic}`,
dir: 'dist',
name: "Colyseus",
format: 'umd',
entryFileNames: 'colyseus-decentraland.js',
entryFileNames: 'colyseus-cocos-creator.js',
sourcemap: true,
amd: { id: pkg.name }
},
Expand All @@ -89,7 +88,7 @@ export default [
alias({
entries: [
// httpie: force XHR implementation on browser/UMD environment
{ find: 'httpie', replacement: './node_modules/httpie/fetch/index.js' },
{ find: 'httpie', replacement: './node_modules/httpie/xhr/index.js' },

// ws: force browser.js version.
{ find: 'ws', replacement: './node_modules/ws/browser.js' },
Expand Down

0 comments on commit 5f39ab6

Please sign in to comment.