Stencil: [1.0.0-beta.1] rollup can't find index.js

Created on 17 May 2019  路  8Comments  路  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:

When I try to build stencil using rollup-plugin-globals plugin as described in the Stencil documentation I am getting a build error around certain modules that use node globals. For example I made a sample repository that uses bufferutils and I get the following output:

[ ERROR ]  Rollup: 
           Could not load 7dba83a5ffbfed604f669155d84753 (imported by
           /Users/matthewsmith/stencil-rollup-test/node_modules/bufferutil/index.js): ENOENT: no such file or
           directory, open '7dba83a5ffbfed604f669155d84753'

I am also having this issue with utf-8-validate on another project.

Expected behavior:

Expect that Stencil builds the project successfully

Steps to reproduce:

I have created a sample repo here but you should be able to reproduce this by including globals() in your stencil.config as described in the Stencil documentation

import globals from 'rollup-plugin-node-globals';
...
  plugins: [
    globals()
  ]

And then using a node module which uses a node-global.

Related code:

Other information:

This issue on rollup itself seemed relevant however I was not able to make it work:
https://github.com/rollup/rollup/issues/470

bug

All 8 comments

Can you confirm that this still happens in beta 2?

confirmed to still not work in beta 2, verbose log output below:

npm run build --verbose
npm info it worked if it ends with ok
npm verb cli [ '/Users/matthewsmith/.nvm/versions/node/v10.15.3/bin/node',
npm verb cli   '/Users/matthewsmith/.nvm/versions/node/v10.15.3/bin/npm',
npm verb cli   'run',
npm verb cli   'build',
npm verb cli   '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb run-script [ 'prebuild', 'build', 'postbuild' ]
npm info lifecycle [email protected]~prebuild: [email protected]
npm info lifecycle [email protected]~build: [email protected]

> [email protected] build /Users/matthewsmith/stencil-rollup-test
> stencil build

[39:46.4]  dev server www root: /Users/matthewsmith/stencil-rollup-test/www, base path: /  MEM:
           102.8MB
[39:46.4]  @stencil/core v1.0.0-beta.2 馃拵

[ WARN  ]  This is a prerelease build, undocumented changes might happen at any time. Technical support is not
           available for prereleases, but any assistance testing is appreciated.

[39:46.4]  darwin, Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz  MEM: 103.1MB
[39:46.4]  cpus: 12, freemem: 3006MB, totalmem: 17180MB  MEM: 103.1MB
[39:46.4]  node v10.15.3  MEM: 103.1MB
[39:46.4]  compiler runtime:
           /Users/matthewsmith/stencil-rollup-test/node_modules/@stencil/core/dist/compiler/index.js 
           MEM: 103.1MB
[39:46.4]  compiler build: 20190520154351  MEM: 103.1MB
[39:46.4]  minifyJs: true, minifyCss: true, buildEs5: true  MEM: 103.1MB
[39:46.4]  compiler workers: 12, tasks per worker: 2  MEM: 103.3MB
[39:46.4]  cache enabled, cacheDir: /Users/matthewsmith/stencil-rollup-test/.stencil  MEM: 103.3MB
[39:46.4]  build, app, prod mode, started ...
[39:46.4]  start build, 2019-05-21T15:39:46  MEM: 103.3MB
[39:46.5]  cleaning 1 dirs ...  MEM: 81.9MB
[39:46.5]  empty dir: /Users/matthewsmith/stencil-rollup-test/www  MEM: 81.9MB
[39:46.5]  cleaning dirs finished in 20 ms  MEM: 82.0MB
[39:46.5]  scan /Users/matthewsmith/stencil-rollup-test/src started ...  MEM: 82.0MB
[39:46.5]  scan for ts files finished: 4 in 15 ms  MEM: 82.1MB
[39:46.5]  transpile started ...
[39:48.0]  load collection: @stencil/router, node_modules/@stencil/router/dist/collection/collection-manifest.json 
           MEM: 146.7MB
[39:48.1]  load collection: @stencil/state-tunnel,
           node_modules/@stencil/state-tunnel/dist/collection/collection-manifest.json  MEM: 153.7MB
[39:48.2]  transpile finished in 1.65 s
[39:48.2]  generated app types started ...  MEM: 156.3MB
[39:48.2]  generated app types finished: src/components.d.ts in 3 ms  MEM: 156.3MB
[39:48.2]  type checking started ...
[39:48.2]  generateEntryModules, 9 entryModules  MEM: 156.6MB
[39:48.2]  generate styles started ...
[39:48.2]  getComponentAssetsCopyTasks: 0  MEM: 156.6MB
[39:48.2]  bundling components started ...
[39:48.3]  generate styles finished in 168 ms
[39:48.7]  generate www started ...  MEM: 180.0MB
[39:48.7]  copyTasks started ...  MEM: 180.0MB
[39:48.7]  generateIndexHtml, write: www/index.html  MEM: 180.1MB
[39:48.7]  generate www finished in 6 ms  MEM: 180.1MB
[39:48.7]  aborted build, 2019-05-21T15:39:46  MEM: 180.1MB
[39:48.7]  generateBuildResults started ...  MEM: 180.1MB
[39:48.7]  generateBuildResults finished in 1 ms  MEM: 180.1MB

[ ERROR ]  Rollup: 
           Could not load 70fe0c732e61909cbdcb08c3593be6 (imported by
           /Users/matthewsmith/stencil-rollup-test/node_modules/bufferutil/index.js): ENOENT: no such file or
           directory, open '70fe0c732e61909cbdcb08c3593be6'

[39:48.7]  build failed in 2.28 s

npm verb lifecycle [email protected]~build: unsafe-perm in lifecycle true
npm verb lifecycle [email protected]~build: PATH: /Users/matthewsmith/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/matthewsmith/stencil-rollup-test/node_modules/.bin:/Users/matthewsmith/.nvm/versions/node/v10.15.3/bin:/Users/matthewsmith/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/matthewsmith/google-cloud-sdk/bin
npm verb lifecycle [email protected]~build: CWD: /Users/matthewsmith/stencil-rollup-test
npm info lifecycle [email protected]~build: Failed to exec build script
npm verb stack Error: [email protected] build: `stencil build`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (/Users/matthewsmith/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
npm verb stack     at EventEmitter.emit (events.js:189:13)
npm verb stack     at ChildProcess.<anonymous> (/Users/matthewsmith/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
npm verb stack     at ChildProcess.emit (events.js:189:13)
npm verb stack     at maybeClose (internal/child_process.js:970:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
npm verb pkgid [email protected]
npm verb cwd /Users/matthewsmith/stencil-rollup-test
npm verb Darwin 18.5.0
npm verb argv "/Users/matthewsmith/.nvm/versions/node/v10.15.3/bin/node" "/Users/matthewsmith/.nvm/versions/node/v10.15.3/bin/npm" "run" "build" "--verbose"
npm verb node v10.15.3
npm verb npm  v6.9.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `stencil build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 3063ms

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/matthewsmith/.npm/_logs/2019-05-21T15_39_48_794Z-debug.log

Confirmed still an issue with @stencil/[email protected] and @stencil/[email protected]

test case updated https://github.com/Matthew-Smith/stencil-rollup-error

May I ask what you are using the globals plugin for? When I remove it, the build succeeds.

Edit: I see, you're using bufferutil which wants to access process.

You can get it to build successfully by passing { dirname: false } as the plugin options, which disables __dirname polyfilling, but it fails at runtime ("os.arch is not a function").

Sorry I forgot about that, I updated the test case with a custom version of rollup-plugin-builtins which I've fixed the os.arch issue. I pushed that custom resolution to my demo.

With the dirname: false flag things do build and things work for the demo however

For reference we use a library which has a dependency on ws which uses bufferutil and utf-8-validate and those are built for node, hence globals and builtins being needed

Confirmed not fixed in @stencil/core1.0.0-beta.5, test case has been updated to beta 5.

However, the library we were using was rappid/jointjs and I was able to hack out the ws dependency so we were able to at least upgrade our project.

This still seems to be a bug but it is no longer blocking my team.

Tested with @stencil/core1.0.0-beta.7 and the build error has gone away however the test now fails when trying to run with the following log in the console:

ReferenceError: module is not defined
    at app-root.entry.js:10

Uncaught (in promise) Error: Constructor for "app-root#undefined" was not found
    at initializeComponent (app-66890872.js:1711)

where app-root.entry.js:10 is:

   try {
       module.exports = require('node-gyp-build')(__dirname);
    } catch (e) {
>     module.exports = require('./fallback');
    }

Note: changing the order of the builtins and globals plugins in the config did not change anything.

Tested with @stencil/core1.0.0-beta.8 and everything works perfectly!

Closing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elmariofredo picture elmariofredo  路  3Comments

ryanmunger picture ryanmunger  路  3Comments

romulocintra picture romulocintra  路  3Comments

lcswillems picture lcswillems  路  3Comments

mitchellsimoens picture mitchellsimoens  路  3Comments