Stencil: [0.17.0-1] Pre-release: Rollup: Plugin Error Cannot read property 'warn' of undefined

Created on 18 Jan 2019  路  16Comments  路  Source: ionic-team/stencil

Stencil version:

 @stencil/[email protected]

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
After reading that pre-release 0.17.0-* fixes https://github.com/ionic-team/stencil-router/issues/86 I installed it. Now I get this but not sure if it is related to the changes by @simonhaenisch :

[ WARN  ]  Bundling Warning
           preferring built-in module 'events' over local alternative at
           '/Users/matthias/Documents/Projekte/bitflower/Case
           OS/Prototype/v0.2/caseos-ui/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this
           behavior or 'preferBuiltins: true' to disable this warning

[ ERROR ]  Rollup: Plugin Error
           Cannot read property 'warn' of undefined

Expected behavior:
Runs dev and build successfully.

Most helpful comment

Hi @simonhaenisch, thank a lot for the hard work!

Your workaround works perfectly:
nodeResolve: { browser: true, preferBuiltins: true } in stencil.config.ts

Will track the rollup plugin issue....

All 16 comments

Hi @adamdbradley, as discussed on Slack here is the repo. I've added you as a collabo as it's private.

https://github.com/bitflower/caseos-ui

Matt

@bitflower do you have a full stack-trace of the plugin error or is that all it throws?

@simonhaenisch DO you mean adding --debug to the call? It gave me this:

[39:13.5]  dev server www root:
           /Users/matthias/Documents/Projekte/bitflower/Case
           OS/Prototype/v0.2/caseos-ui/www, base url: /
           MEM: 106.0MB
[39:13.5]  @stencil/core v0.17.0 馃攽
[39:13.5]  darwin, Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz,
           cpus: 8  MEM: 106.2MB
[39:13.5]  node v10.14.1  MEM: 106.2MB
[39:13.5]  compiler runtime:
           /Users/matthias/Documents/Projekte/bitflower/Case
           OS/Prototype/v0.2/caseos-ui/node_modules/@stencil/core/dist/compiler/index.js
            MEM: 106.2MB
[39:13.5]  compiler build: 190018190054  MEM: 106.2MB
[39:13.6]  compiler workers: 8, tasks per worker: 2  MEM:
           106.4MB
[39:13.6]  minifyJs: true, minifyCss: true, buildEs5: true
           MEM: 106.4MB
[39:13.6]  cache enabled, cacheDir:
           /Users/matthias/Documents/Projekte/bitflower/Case
           OS/Prototype/v0.2/caseos-ui/.stencil  MEM:
           106.4MB
[39:13.6]  build, app, prod mode, started ...
[39:13.6]  start build, 2019-01-20T12:39:13  MEM:
           106.5MB
[39:13.6]  empty dir:
           /Users/matthias/Documents/Projekte/bitflower/Case
           OS/Prototype/v0.2/caseos-ui/www  MEM:
           90.6MB
[39:13.7]  scan
           /Users/matthias/Documents/Projekte/bitflower/Case
           OS/Prototype/v0.2/caseos-ui/src started ...
[39:13.7]  scan for ts files finished: 87 in 55 ms
[39:13.7]  buildTsService started ...
[39:13.8]  buildTsService finished in 6 ms
[39:13.8]  transpile started ...
[39:15.3]  load collection: @stencil/redux,
           node_modules/@stencil/redux/dist/collection/collection-manifest.json
            MEM: 163.5MB
[39:15.5]  load collection: @stencil/router,
           node_modules/@stencil/router/dist/collection/collection-manifest.json
            MEM: 168.6MB
[39:15.5]  load collection: @stencil/state-tunnel,
           node_modules/@stencil/state-tunnel/dist/collection/collection-manifest.json
            MEM: 166.1MB
[39:15.7]  load collection: @ionic/core,
           node_modules/@ionic/core/dist/collection/collection-manifest.json
            MEM: 176.2MB
[39:15.7]  load collection: ionicons,
           node_modules/ionicons/dist/collection/collection-manifest.json
            MEM: 176.4MB
[39:15.8]  load collection: @case-os/ui-kit,
           node_modules/@case-os/ui-kit/dist/collection/collection-manifest.json
            MEM: 178.2MB
[39:16.1]  transpile finished in 2.34 s
[39:16.1]  generated src/components.d.ts  MEM: 189.4MB
[39:16.1]  validateTypes started ...
[39:16.1]  upgrade @stencil/redux started ...
[39:16.1]  Add_Component_Dependencies, @stencil/redux, compiled
           by v0.2.2  MEM: 190.9MB
[39:16.1]  upgrade @stencil/router started ...
[39:16.1]  upgrade @stencil/state-tunnel started ...
[39:16.1]  upgrade @ionic/core started ...
[39:16.1]  upgrade ionicons started ...
[39:16.1]  upgrade @case-os/ui-kit started ...
[39:16.1]  upgrade @stencil/redux finished in 4 ms
[39:16.2]  upgrade @stencil/router finished in 62 ms
[39:16.2]  upgrade @stencil/state-tunnel finished in 62
           ms
[39:16.3]  upgrade ionicons finished in 221 ms
[39:16.4]  upgrade @case-os/ui-kit finished in 255 ms
[39:16.5]  upgrade @ionic/core finished in 382 ms
[39:16.5]  generateEntryModules, 49 entryModules  MEM:
           201.7MB
[39:16.5]  getComponentAssetsCopyTasks: 2  MEM:
           201.7MB
[39:16.5]  module map started ...
[39:16.5]  generate styles started ...
[39:16.5]  getConfigCopyTasks: 2  MEM: 202.3MB
[39:16.5]  copyTasks started ...
[39:16.5]  createBundle started ...
[39:16.9]  cache had 190 failed ops, skip disk ops for remander
           of build  MEM: 211.0MB
[39:17.6]  copyTasks finished in 1.11 s
[39:18.5]  compile global style start ...
[39:19.0]  global style: www/build/app.css  MEM:
           262.0MB
[39:19.0]  compile global style finish in 560 ms
[39:19.0]  generate styles finished in 2.51 s
[39:19.9]  createBundle finished in 3.35 s
[39:19.9]  module derive started ...
[39:19.9]  module derive finished in less than 1 ms
[39:19.9]  module map finished in 3.37 s
[39:19.9]  aborted build, 2019-01-20T12:39:13  MEM:
           303.6MB
[39:19.9]  generateBuildResults started ...
[39:19.9]  generateBuildResults finished in 6 ms

[ WARN  ]  @Method requires async: src/components/shared/app-form/app-form-rich-input.tsx
           External @Method() validate() should return a
           Promise or void. Consider prefixing the method with
           async, such as @Method async validate(). Next minor
           release will error.

[ WARN  ]  @Method requires async: src/components/shared/app-form/app-form-text-input.tsx
           External @Method() validate() should return a
           Promise or void. Consider prefixing the method with
           async, such as @Method async validate(). Next minor
           release will error.

[ WARN  ]  Bundling Warning
           preferring built-in module 'events' over local
           alternative at
           '/Users/matthias/Documents/Projekte/bitflower/Case
           OS/Prototype/v0.2/caseos-ui/node_modules/events/events.js',
           pass 'preferBuiltins: false' to disable this
           behavior or 'preferBuiltins: true' to disable this
           warning

[ ERROR ]  Rollup: Plugin Error
           Cannot read property 'warn' of undefined

[39:19.9]  build failed in 6.33 s

I can add you as collaborator to the private repo?

The repo uses stencil-sass and it's rollup version is 0.66.2. Might that be a problem?

I forked @stencil/sass and updated rollup. Doesn't change anything. Then as a last resort disabled all plugins in my stencil.config.ts and I still get the error indicating a "plugin error". Are there any "hidden" plugins running in the background?

@bitflower there is a couple plugins being used and a few custom ones:

https://github.com/ionic-team/stencil/blob/adc94ce4028eeff2bd1b2c6cd700ab9cd0171371/src/compiler/bundle/rollup-bundle.ts#L46-L62

Just searching through the source, the most likely reason I can think of is that it's related to a copy task (i. e. trying to access .warn of a copy task but the task is undefined). But I'm not sure how that would be a plugin error. I can try help you debug it tonight if you want.

That would be awesome, I have added you to the repo at: https://github.com/bitflower/stencil-rollup-issues

Just npm run dev it....

I think the issue is related to rollup-plugin-node-resolve (opened an issue there: https://github.com/rollup/rollup-plugin-node-resolve/issues/196), and can be prevented by setting preferBuiltins to either true or false in the Stencil config (because if it's not set, the plugin tries to throw a warning but the plugin's context somehow is undefined and so it can't access .warn).

I'm not exactly sure how it all happens though, because this is the rollup error being caught:

{ TypeError: Cannot read property 'warn' of undefined
    at ~/stencil/dist/sys/node/index.js:38090:16
    at <anonymous> code: 'PLUGIN_ERROR', plugin: 'commonjs', hook: 'resolveId' }

I added a console.log and the importee causing it is events which is imported by @featherjs/feathers. The first time it actually works and throws the "Bundling Warning" that is in your logs, but then it trys to call it again (twice) and that's when the error happens. Because the causing plugin is reported as commonjs, I assume that the issue is coming from there (maybe it uses node-resolve internally or something?).

Hi @simonhaenisch, thank a lot for the hard work!

Your workaround works perfectly:
nodeResolve: { browser: true, preferBuiltins: true } in stencil.config.ts

Will track the rollup plugin issue....

I guess this can be closed then?

Just letting you know that the upstream issue has been fixed in https://github.com/rollup/rollup-plugin-commonjs/pull/370, so we'll just need to make sure that Stencil uses a version >= v9.2.1.

Awesome, thanks for following the topic and keep us informed! WIll the Stencil core team check this thread out? Or can you make a PR for that?

Was this page helpful?
0 / 5 - 0 ratings