Skip to content

Webpack Plugin fails to import on Node 4 #6608

Closed
@trickeyone

Description

@trickeyone

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

node: v4.8.3
npm: 5.0.3

Repro steps.

Just attempting to import the plugin using node v4 causes the error.

The log given by the failure.

/path/to/code/node_modules/@ngtools/webpack/src/plugin.js:8
const { __NGTOOLS_PRIVATE_API_2 } = require('@angular/compiler-cli');
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/path/to/code/node_modules/@ngtools/webpack/src/index.js:30:10)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/path/to/code/webpack.config.js:3:19)
    at Module._compile (module.js:409:26)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch:js: `webpack --watch --progress --colors`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build:js script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I tracked the change that's causing the issue to commit #507b39984ad71eab48bec1f933492acb653e90df

The package.json is indicating that this version is compatible with node >= 4.1.0

Desired functionality.

I tried changing the line to const __NGTOOLS_PRIVATE_API_2 = require('@angular/compiler-cli').__NGTOOLS_PRIVATE_API_2; but there were other instances:

  • line 67: const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
  • line 261: _translateSourceMap(sourceText, fileName, { line, character }) {
  • line 299: let { line, character, fileName } = this._translateSourceMap(sourceText, diagnostic.file.fileName, position);
  • line 368: const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);

Of which I started running into it in src/refactor.js and I couldn't keep tracking.

Mention any other details that might be useful.

I would rather not use a beta version, but it looks like that was the last time node 4 was actually supported.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions