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

Rollup: Plugin Error unexpected token #1305

Closed
Matthew-Smith opened this issue Jan 7, 2019 · 12 comments
Closed

Rollup: Plugin Error unexpected token #1305

Matthew-Smith opened this issue Jan 7, 2019 · 12 comments
Labels

Comments

@Matthew-Smith
Copy link
Contributor

Matthew-Smith commented Jan 7, 2019

Stencil version:

 @stencil/core@0.16.1

EDIT: recently tested with

@stencil/core@0.17.0

EDIT 2: recently tested with

@stencil/core@0.18.0

Node Version:

v10.12.0

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:

I am unable to finish building our project when I use the rollup-plugin-node-globals plugin in the stencil.config.ts

Getting this error output:

[ ERROR ]  Rollup: Plugin Error
           Unexpected token (5:17675) in
           /Users/matthewsmith/stencil-rollup-test/node_modules/@stencil/state-tunnel/dist/esm/es5/stencil-state-tunnel.core.js

[ ERROR ]  TypeError: Cannot read property 'cache' of undefined at
           /Users/matthewsmith/stencil-rollup-test/node_modules/@stencil/core/dist/compiler/index.js:24073:48
           at Generator.throw (<anonymous>) at rejected
           (/Users/matthewsmith/stencil-rollup-test/node_modules/@stencil/core/dist/compiler/index.js:30:65)

Expected behavior:

The app should build and be able to build successfully

Steps to reproduce:

Add rollup-plugin-node-globals based on the instructions from stencil's module-bundling docs

Alternatively you can clone this sample, npm install and then npm run build in it
https://github.com/Matthew-Smith/stencil-rollup-error
https://github.com/Matthew-Smith/stencil-rollup-error/tree/34810a9c393cf0cd0200a4e53df8fc32d6a3308a

Related code:

stencil.config.ts

import { Config } from '@stencil/core';
import globals from 'rollup-plugin-node-globals';

// https://stenciljs.com/docs/config

export const config: Config = {
  globalStyle: 'src/global/app.css',
  globalScript: 'src/global/app.ts',
  outputTargets: [
    {
      type: 'www',
      // uncomment the following line to disable service workers in production
      // serviceWorker: null
    }
  ],
  plugins: [
    globals(),
  ]
};

package.json

{
  "name": "test-rollup",
  "private": true,
  "version": "0.0.1",
  "description": "Stencil App Starter",
  "scripts": {
    "build": "stencil build",
    "start": "stencil build --dev --watch --serve",
    "test": "stencil test --spec --e2e",
    "test.watch": "stencil test --spec --e2e --watchAll"
  },
  "dependencies": {
    "@stencil/core": "~0.16.1",
    "@stencil/router": "~0.3.1",
    "rollup-plugin-node-globals": "^1.4.0"
  },
  "license": "MIT"
}

Other information:

Issue 1063 seems like it could be relevant but the solution was to downgrade versions which isn't ideal

@ionitron-bot ionitron-bot bot added the triage label Jan 7, 2019
@Matthew-Smith
Copy link
Contributor Author

Tested with Stencil 0.16.2 and the TypeError: cannot read property 'cache' of undefined issue seems to have been resolved but rollup plugin still fails

@snaptopixel
Copy link
Contributor

snaptopixel commented Jan 8, 2019

Did you try it with both builtins and globals?

@Matthew-Smith
Copy link
Contributor Author

Matthew-Smith commented Jan 8, 2019

@snaptopixel, I did and sadly that didn't change anything. Should I have left that in the example? I figured it added unnecessary extra code.

@Matthew-Smith
Copy link
Contributor Author

Tested with Stencil 0.17.0 and the Rollup: Plugin Error still occurs. Here is full debug build output from the simple example repo:

> ./node_modules/@stencil/core/bin/stencil build --debug
[05:58.6]  dev server www root: /Users/matthewsmith/stencil-rollup-test/www, base url: /  MEM:
           110.1MB
[05:58.6]  @stencil/core v0.17.0 🔑
[05:58.6]  darwin, Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz, cpus: 12  MEM: 110.4MB
[05:58.6]  node v10.12.0  MEM: 110.4MB
[05:58.6]  compiler runtime:
           /Users/matthewsmith/stencil-rollup-test/node_modules/@stencil/core/dist/compiler/index.js
           MEM: 110.4MB
[05:58.6]  compiler build: 190018190054  MEM: 110.4MB
[05:58.7]  compiler workers: 12, tasks per worker: 2  MEM: 110.9MB
[05:58.7]  minifyJs: true, minifyCss: true, buildEs5: true  MEM: 110.9MB
[05:58.7]  cache enabled, cacheDir: /Users/matthewsmith/stencil-rollup-test/.stencil  MEM: 111.0MB
[05:58.7]  build, app, prod mode, started ...
[05:58.7]  start build, 2019-01-21T21:05:58  MEM: 111.3MB
[05:58.8]  empty dir: /Users/matthewsmith/stencil-rollup-test/www  MEM: 94.0MB
[05:58.8]  scan /Users/matthewsmith/stencil-rollup-test/src started ...
[05:58.8]  scan for ts files finished: 4 in 10 ms
[05:58.8]  buildTsService started ...
[05:58.8]  buildTsService finished in 7 ms
[05:58.8]  transpile started ...
[06:00.2]  load collection: @stencil/router, node_modules/@stencil/router/dist/collection/collection-manifest.json
           MEM: 143.9MB
[06:00.2]  load collection: @stencil/state-tunnel,
           node_modules/@stencil/state-tunnel/dist/collection/collection-manifest.json  MEM: 144.0MB
[06:00.2]  transpile finished in 1.46 s
[06:00.2]  generated src/components.d.ts  MEM: 144.3MB
[06:00.2]  validateTypes started ...
[06:00.2]  upgrade @stencil/router started ...
[06:00.2]  upgrade @stencil/state-tunnel started ...
[06:00.3]  upgrade @stencil/state-tunnel finished in 47 ms
[06:00.3]  upgrade @stencil/router finished in 61 ms
[06:00.3]  generateEntryModules, 3 entryModules  MEM: 144.6MB
[06:00.3]  getComponentAssetsCopyTasks: 0  MEM: 144.6MB
[06:00.3]  module map started ...
[06:00.3]  generate styles started ...
[06:00.3]  getConfigCopyTasks: 2  MEM: 144.7MB
[06:00.3]  copyTasks started ...
[06:00.3]  createBundle started ...
[06:00.3]  copyTasks finished in 17 ms
[06:00.5]  compile global style start ...
[06:00.7]  createBundle finished in 364 ms
[06:00.7]  module derive started ...
[06:00.7]  module derive finished in less than 1 ms
[06:00.7]  module map finished in 368 ms
[06:00.7]  global style: www/build/app.css  MEM: 153.6MB
[06:00.7]  compile global style finish in 174 ms
[06:00.7]  generate styles finished in 368 ms
[06:00.7]  aborted build, 2019-01-21T21:05:58  MEM: 153.6MB
[06:00.7]  generateBuildResults started ...
[06:00.7]  generateBuildResults finished in less than 1 ms

[ ERROR ]  Rollup: Plugin Error
           Unexpected token (5:17675) in
           /Users/matthewsmith/stencil-rollup-test/node_modules/@stencil/state-tunnel/dist/esm/es5/stencil-state-tunnel.core.js

[06:00.7]  build failed in 2.00 s

@Matthew-Smith
Copy link
Contributor Author

Same bug reported on @stencil/router: stencil-community/stencil-router#83

@Matthew-Smith
Copy link
Contributor Author

Tested with Stencil 0.18.0 still not working

@davidquintard
Copy link

What about this issue?

@x1c0
Copy link

x1c0 commented Apr 5, 2019

I have the same issue, this happened because I needed to connect with some third party SDK together with the router, without the router I can use the SDK without any issue

"@directus/sdk-js": "^5.2.1",
"@stencil/core": "~0.16.2",
"@stencil/router": "~0.3.1"

stencil.config.ts

import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';

export const config: Config = {
...
 plugins: [
   builtins(),
   globals(),
 ],
...

@Matthew-Smith
Copy link
Contributor Author

Matthew-Smith commented Apr 30, 2019

This exact issue seems to be "fixed" with stencil one (tested on 1.0.0-alpha.14) however I have found that there is another issue with using the same rollup plugins.

This is the new error:

[ ERROR ]  Rollup: 
           Could not load node-globals:dirname (imported by
           /Users/matthewsmith/stencil-rollup-test/node_modules/bufferutil/index.js): Path must be a string
           without null bytes

NOTE: This appears on this github issue: calvinmetcalf/rollup-plugin-node-globals#18

However the resolution appears to be just changing the order of the rollup plugins which isn't possible with anything stencil uses internally.

I was able to reproduce the issue with a minimal test (based off of the stencil init app). This test is located on master of https://github.com/Matthew-Smith/stencil-rollup-error

@gleitz
Copy link

gleitz commented Apr 30, 2019

Very interested to see this fixed. Really want to upgrade to Stencil 1.0.0

@seanwuapps
Copy link

Having same issue with

"@stencil/core": "^0.18.1",
"@stencil/router": "^0.3.3",

which are installed using @latest flag

@Matthew-Smith
Copy link
Contributor Author

This issue appears to be resolved with stencil one however I have reported another issue here:

#1541

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

No branches or pull requests

6 participants