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

Unexpected Token when minifying three.js and globe.js #57

Open
MinaMatta98 opened this issue Aug 9, 2024 · 1 comment
Open

Unexpected Token when minifying three.js and globe.js #57

MinaMatta98 opened this issue Aug 9, 2024 · 1 comment

Comments

@MinaMatta98
Copy link

Hello,

Thank you for this awesome tool.

I am receiving the following error when minifying my project:

/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2929
    throw err
    ^

SyntaxError: Unexpected token (7:598206)
    at pp$4.raise (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2927:15)
    at pp.unexpected (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:698:10)
    at pp$3.parseExprAtom (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2326:12)
    at _class.parseExprAtom (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn-node/lib/dynamic-import/index.js:77:117)
    at pp$3.parseExprSubscripts (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2129:21)
    at pp$3.parseMaybeUnary (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2106:19)
    at _class.parseMaybeUnary (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn-node/lib/private-class-elements/index.js:122:54)
    at pp$3.parseExprOps (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2041:21)
    at pp$3.parseMaybeConditional (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2024:21)
    at pp$3.parseMaybeAssign (/home/mina/Documents/PMSoftware/Tender/Tender Attempt - 0003/codebase/globe/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:1997:21) {
  pos: 602507,
  loc: Position { line: 7, column: 598206 },
  raisedAt: 602508
}

Node.js v22.5.1

Node Version:

node -v

v22.5.1

Command Run:

browserify -p tinyify index-D9djZuPL.js -o index.js

TsConfig:

cat tsconfig.json

{
	"compilerOptions": {
		"target": "ES2020",
		"useDefineForClassFields": true,
		"module": "ESNext",
		"lib": [
			"ES2020",
			"DOM",
			"DOM.Iterable"
		],
		"skipLibCheck": true,
		"checkJs": false,
		/* Bundler mode */
		"moduleResolution": "bundler",
		"allowImportingTsExtensions": true,
		"isolatedModules": true,
		"moduleDetection": "force",
		"noEmit": true,
		/* Linting */
		"strict": false,
		"noUnusedLocals": false,
		"noUnusedParameters": true,
		"noFallthroughCasesInSwitch": true
	},
	"include": [
		"src"
	]
}

Package.json

cat package.json

{
  "name": "globe",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview"
  },
  "devDependencies": {
    "@types/jquery": "^3.5.30",
    "jquery": "^3.7.1",
    "tinyify": "^4.0.0",
    "typescript": "^5.5.3",
    "vite": "^5.4.0"
  },
  "dependencies": {
    "@types/three": "^0.167.1",
    "globe.gl": "^2.32.5",
    "three": "^0.167.1"
  }
}

The file to be minified can be found on: https://drive.google.com/file/d/1DuqHZAO_CDXJm1prnJArkI4cShG9EIkW/view?usp=sharing

Any help would be greatly appreciated

@MinaMatta98
Copy link
Author

Hello,

This is solved when I first do a conversion with the following:

browserify scriptName.js -o bundle.js -t [ babelify --presets [ @babel/preset-env @babel/preset-react ] --plugins [ @babel/plugin-transform-class-properties ] ]

and then run

browserify -p tinyify bundle.js -o index.js

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