Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Production build fails with ES6 javascript files in the project #158

Closed
@tko

Description

@tko

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Didn't try.

Which terms did you search for in User Guide?

npm run build fails to minify

Basically if you follow the step "3. If the dependency is small enough, copy it to your src/ folder and treat it as application code." in react-scripts-ts project you get this bug.

Environment

  1. npm ls react-scripts-ts (if you haven’t ejected): react-scripts-ts@2.6.0
  2. node -v: v8.2.1
  3. npm -v: 5.3.0
  4. yarn --version (if you use Yarn): 0.27.5
  5. npm ls react-scripts-ts (if you haven’t ejected):
    test@0.1.0 /private/tmp/test
    └── react-scripts-ts@2.6.0
    

Then, specify:

  1. Operating system: macos 10.11.6 (15G1611)
  2. Browser and version (if relevant): N/A

Steps to Reproduce

Add an import of ES6 javascript (.js) file and run build:

  1. create-react-app --scripts-version=react-scripts-ts test
  2. cd test
  3. echo 'export default class Test {}' > src/Test.js
  4. add to src/App.tsx:
    import Test from './Test';
    console.log('Test', Test);
  5. yarn run build

In the real-world example I encountered this the javascript file is a dependency that I can only copypaste into the project as it is not distributed otherwise.

Expected Behavior

Successful production build.

Actual Behavior

Development server works, but production build fails.

yarn run build:

yarn run v0.27.5
$ react-scripts-ts build
Creating an optimized production build...
Warning: The 'no-use-before-declare' rule requires type information.
ts-loader: Using typescript@2.4.2 and /private/tmp/test/tsconfig.json
Failed to compile.

static/js/main.ff9586e3.js from UglifyJs
Unexpected token: name (Test) [./~/source-map-loader!./src/Test.js:1,0][static/js/main.ff9586e3.js:21758,6]

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The code on line 21758 is class Test { -- the code around it:

/* 178 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
class Test {
}
/* harmony export (immutable) */ __webpack_exports__["a"] = Test;



/***/ }),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions