sibiraj-s / ngx-editor

🖋️ Rich Text Editor for angular using ProseMirror
https://sibiraj-s.github.io/ngx-editor/
MIT License
424 stars 183 forks source link

Build error when compiling as part of a package with ng-packagr #50

Closed stephanos199 closed 6 years ago

stephanos199 commented 6 years ago
BUILD ERROR
'fromTextArea' is not exported by node_modules\codemirror\lib\codemirror.js
Error: 'fromTextArea' is not exported by node_modules\codemirror\lib\codemirror.js
    at error (\node_modules\rollup\dist\rollup.js:185:14)
    at Module.error (\node_modules\rollup\dist\rollup.js:16526:3)
    at Module.trace (\node_modules\rollup\dist\rollup.js:16623:10)
    at ModuleScope.findVariable (\node_modules\rollup\dist\rollup.js:13965:22)
    at FunctionScope.findVariable (\node_modules\rollup\dist\rollup.js:11543:33)
    at Scope.findVariable (\node_modules\rollup\dist\rollup.js:11543:33)
    at FunctionScope.findVariable (\node_modules\rollup\dist\rollup.js:11543:33)
    at Scope.findVariable (\node_modules\rollup\dist\rollup.js:11543:33)
    at BlockScope.findVariable (\node_modules\rollup\dist\rollup.js:11543:33)
    at Node._bindVariableIfMissing (\node_modules\rollup\dist\rollup.js:12626:31)

To reproduce create a project, use the component and then try to compile using ng packagr

stephanos199 commented 6 years ago

I'm using version 3.3.0-rc.3 of the editor and have codemirror version 5.34.0 as a peer dependency.

sibiraj-s commented 6 years ago

That's odd. I was using that version in our product. Which is in production actually.

You can see a working example here: https://ngx-editor.stackblitz.io/ Code for the example: https://stackblitz.com/edit/ngx-editor

Are You using ng-packagr to pack your code having this editor?

if so, try adding this to your ngPackage configuration

https://github.com/Sibiraj-S/ngx-editor/blob/62f4522c1fabebfd700468c399d3df8fb3148659/ng-package.json#L5-L10

Post More Information such as

  1. Angular version
  2. Operation System
  3. Nodejs version

If nothing helps.

sibiraj-s commented 6 years ago

@stephanos199 . Did that help?

stephanos199 commented 6 years ago

I only had to add

{
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
  "lib": {
    "entryFile": "public_api.ts",
    "externals": {
      "codemirror": "codemirror"
    }
  }
}

I was missing the "externals" declaration

sibiraj-s commented 6 years ago

So Is it working now?

stephanos199 commented 6 years ago

Yes

sibiraj-s commented 6 years ago

Closing as PROBLEM RESOLVED

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in the thread.