Skip to content

Production build with ES6 classes causes errors from UglifyJS #2

@slogsdon

Description

@slogsdon

Running preact build with the default tsconfig.json and preact.config.js files created by this plugin cause the following with a recently created Preact application (created with preact-cli):

[at-loader] Checking started in a separate process...

[at-loader] Ok, 0.732 sec.
0.chunk.32652.js from UglifyJs
Unexpected token: name (Profile) [./routes/profile/index.tsx:4,14][0.chunk.32652.js:20,6]
1.chunk.f5e4c.js from UglifyJs
Unexpected token: name (PostList) [./routes/posts/index.tsx:15,0][1.chunk.f5e4c.js:24,6]
2.chunk.d1976.js from UglifyJs
Unexpected token: name (Post) [./routes/post/index.tsx:15,14][2.chunk.d1976.js:12,6]
bundle.958ca.js from UglifyJs
Unexpected token: punc ()) [./components/app.tsx:12,43][bundle.958ca.js:913,165]
Build failed!

I got around the issue by adding the following to tsconfig.json:

 {
   "compileOnSave": false,
   "compilerOptions": {
     "target": "es2017",
     "module": "esnext",
     "moduleResolution": "node",
     "sourceMap": true,
     "jsx": "react",
     "jsxFactory": "h",
     "allowJs": false
+  },
+  "exclude": [
+    "node_modules"
+  ],
+  "awesomeTypescriptLoaderOptions": {
+    "useBabel": true,
+    "useCache": true
+  }
 }

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions