Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bitflower opened this issue Jan 18, 2019 · 16 comments

Comments

@bitflower
Copy link
Contributor

Stencil version:

 @stencil/core@0.17.0-1

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 stencil-community/stencil-router#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.

@ionitron-bot ionitron-bot bot added the triage label Jan 18, 2019
@bitflower
Copy link
Contributor Author

Maybe also related to #1306

@bitflower
Copy link
Contributor Author

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

@simonhaenisch
Copy link
Contributor

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

@bitflower
Copy link
Contributor Author

@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

@bitflower
Copy link
Contributor Author

I can add you as collaborator to the private repo?

@bitflower
Copy link
Contributor Author

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

@bitflower
Copy link
Contributor Author

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?

@simonhaenisch
Copy link
Contributor

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

plugins: [
abortPlugin(buildCtx),
config.sys.rollup.plugins.nodeResolve(nodeResolveConfig),
config.sys.rollup.plugins.emptyJsResolver(),
config.sys.rollup.plugins.commonjs(commonjsConfig),
bundleJson(config),
inMemoryFsRead(config, compilerCtx, buildCtx, entryModules),
pathsResolution(config, compilerCtx, tsCompilerOptions),
localResolution(config, compilerCtx),
rollupPluginReplace({
values: replaceObj
}),
...config.plugins,
statsPlugin(buildCtx),
pluginHelper(config, compilerCtx, buildCtx),
abortPlugin(buildCtx)
],

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.

@bitflower
Copy link
Contributor Author

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

@bitflower
Copy link
Contributor Author

Just npm run dev it....

@simonhaenisch
Copy link
Contributor

simonhaenisch commented Jan 21, 2019

I think the issue is related to rollup-plugin-node-resolve (opened an issue there: rollup/rollup-plugin-node-resolve#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?).

@bitflower
Copy link
Contributor Author

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....

@bitflower
Copy link
Contributor Author

I guess this can be closed then?

@simonhaenisch
Copy link
Contributor

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

@bitflower
Copy link
Contributor Author

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?

@simonhaenisch simonhaenisch reopened this Feb 25, 2019
simonhaenisch added a commit that referenced this issue Feb 25, 2019
rollup-plugin-commonjs@9.2.1 fixes an upstream issue that caused a build
error when conflicting packages exist and preferBuiltins is unset.

Closes #1326.
@ionitron-bot ionitron-bot bot removed the triage label Apr 3, 2019
@simonhaenisch
Copy link
Contributor

Current master now has rollup-plugin-commonjs@9.2.1:

"rollup-plugin-commonjs": "9.2.1",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants