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

Api object recurrence causes an error when working with typescript. #37

Closed
AliLozano opened this issue Aug 4, 2019 · 11 comments
Closed
Labels
bug Something isn't working cli plugin

Comments

@AliLozano
Copy link

AliLozano commented Aug 4, 2019

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Install "@vue/cli-plugin-typescript": "^3.8.0" and put uvue after it dependence in package.json

Expected behavior
Run npm run ssr:build or npm run build

It throw error

TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at PoolWorker.writeJson (/projects/project/node_modules/thread-loader/dist/WorkerPool.js:116:44)
    at PoolWorker.run (/projects/project/node_modules/thread-loader/dist/WorkerPool.js:100:10)
    at WorkerPool.distributeJob (/projects/project/node_modules/thread-loader/dist/WorkerPool.js:332:15)
    at runQueue (/projects/project/node_modules/thread-loader/node_modules/neo-async/async.js:8097:9)
    at process._tickCallback (internal/process/next_tick.js:61:11)
 ERROR  Error: Command failed: /projects/project/node_modules/@vue/cli-service/bin/vue-cli-service.js build --modern
Error: Command failed: /projects/project/node_modules/@vue/cli-service/bin/vue-cli-service.js build --modern
    at makeError (/projects/project/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/projects/project/node_modules/execa/index.js:278:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I don't know if is a typescript loader, but moving dependence, it fails,

I've identified that problem is this:
@uvue/vue-cli-plugin-ssr/uvue/index.js

constructor(api) { // Constructor de UVueApi
    this.api = api;

and
@uvue/vue-cli-plugin-ssr/index.js

  api.uvue = new UVueAPI(api);

After the PoolWorker wants to serialize it and it fails.

I have a solution, but it need to you evaluate it, and add a test. I will pull request.

@AliLozano AliLozano changed the title Appeal object recurrence causes an error when working with typescript. Api object recurrence causes an error when working with typescript. Aug 4, 2019
@yabab-dev
Copy link
Contributor

Hi,

Sorry for late response, but actually I cannot reproduce your issue.
Can you provide a repository ?

Thanks !

@AliLozano
Copy link
Author

AliLozano commented Aug 27, 2019

Here is:

Steps:

Create a project with this: vue-router, vuex, dart-sass, babel, typescript, pwa, eslint, unit-jest, e2e-cypress

vue create foobar 
vue add @uvue/sur

When run npm run serve page is in blank.
When run npm run build page is in blank.
When run npm run ssr:serve it works.
When run npm run ssr:build it works.

Change package.json order: (@uvue/vue-cli-plugin-ssr after@vue/cli-plugin-typescript) https://github.com/AliLozano/uvue-typescript-issue

When run npm run serve it works
When run npm run build it works
When run npm run ssr:serve it fails with circular reference
When run npm run ssr:build it fails with circular reference

With my pull request, both works.

@yabab-dev
Copy link
Contributor

Hi, I've tested your procedure and I am able to only reproduce the first issue (blank page) but cannot reproduce the circular to JSON issue.

Can you give me your NodeJS version ?

@AliLozano
Copy link
Author

AliLozano commented Aug 27, 2019

Did you download my repo?, in my repo I've changed the package order. https://github.com/AliLozano/uvue-typescript-issue

screen

My node version is v10.16.0

@yabab-dev
Copy link
Contributor

Yep, I've take your repo and I'm on same node version.

@yabab-dev
Copy link
Contributor

OK I've reproduced the issue but only with ssr:build command. Vue CLI enable thread-loader in production builds, and this one call JSON.stringify.

As a workaround, you can setup your vue.config.js like this:

module.exports = {
  parallel: false,
};

I'll close your PR and I'll try find a better way to solve this issue.

@yabab-dev yabab-dev added bug Something isn't working cli plugin and removed need repro labels Aug 27, 2019
@AliLozano
Copy link
Author

Thanks I'll be waiting :).

yabab-dev added a commit that referenced this issue Aug 27, 2019
@AliLozano
Copy link
Author

Can you see why In default package order, npm run serve gives a blank page?

@yabab-dev
Copy link
Contributor

It will be fixed in next version.

As a workaround, you can put this in vue.config.js:

module.exports = {
  chainWebpack(config) {
    config.entryPoints
      .get('app')
      .clear()
      .add(require.resolve('@uvue/core/client'));
  },
};

(On next update of this plugin, you need to remove this code)

@AliLozano
Copy link
Author

Thanks :)

@yabab-dev
Copy link
Contributor

Fixed in v0.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli plugin
Projects
None yet
Development

No branches or pull requests

2 participants