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

Docz not building on Windows #783

Closed
ejuo opened this issue Apr 10, 2019 · 9 comments
Closed

Docz not building on Windows #783

ejuo opened this issue Apr 10, 2019 · 9 comments
Labels
stale v1 v2 windows Windows specific issue

Comments

@ejuo
Copy link
Contributor

ejuo commented Apr 10, 2019

Bug Report

Get error when build Docz v1.0.0-rc.8 (all v1 same error).

...
...
...
src/ast.ts, src/codesandbox.ts, src/format.ts, src/fs.ts, src/index.ts, src/imports.ts, src/jsx.ts, src/mdast.ts → lib...
[!] Error: './format' is imported as an external by src\codesandbox.ts, but is already an existing non-external module id.
Error: './format' is imported as an external by src\codesandbox.ts, but is already an existing non-external module id.
    at error (C:\Git\docz.next\docz-master\node_modules\rollup\dist\rollup.js:3598:30)
    at C:\Git\docz.next\docz-master\node_modules\rollup\dist\rollup.js:18014:21
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
error Command failed with exit code 1.

to fix this I take only 1 entry 'src/index.ts' in rollup.config.js.
Then after successfully build, all tests failed

Test Suites: 1 failed, 1 total
Tests:       6 failed, 6 total
Snapshots:   6 failed, 6 total
Time:        6.887s
Ran all test suites.
error Command failed with exit code 1.

To Reproduce

  1. clone docz.
  2. yarn install
  3. yarn bs
  4. yarn packages

I suspect, rollup don't resolves dependences, all bundles has links to src .ts files.
Example:
index.esm.js from docz-utils contains

export * from './ast.ts';
export * from './codesandbox.ts';
export * from './fs.ts';
export * from './imports.ts';
export * from './jsx.ts';
export * from './mdast.ts';
export { format } from './format.ts';

Expected behavior

It should build completly bundles.

Environment

  • OS: Windows 10
  • yarn 1.13.0 (or npm 6.5.0),
  • node 11.13.0 (or 10.15.0)
@fi3ework
Copy link
Contributor

fi3ework commented Apr 10, 2019

Not sure exactly why. How about run yarn build in docz-utils packages, can it build successfully? For me, I must precompile docz-utils manually otherwise yarn packages will fail. But it might be a problem of rollup with Windows under this issue.

@ejuo
Copy link
Contributor Author

ejuo commented Apr 10, 2019

I separate docz-utils to new folder. Add docz-rollup@next and other required modules. Take parent tsconfig.json from docz. And made: yarn, yarn build and got same error, full trace:

C:\Git\docz.next\docz-utils>yarn build
yarn run v1.13.0
$ trash lib && cross-env NODE_ENV=production rollup -c

src/ast.ts, src/codesandbox.ts, src/format.ts, src/fs.ts, src/index.ts, src/imports.ts, src/jsx.ts, src/mdast.ts → lib...
(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en#error-this-is-undefined
src\codesandbox.ts
1: var _this = this;
               ^
2: import * as tslib_1 from "tslib";
3: import * as path from 'path';
src\fs.ts
1: var _this = this;
               ^
2: import * as tslib_1 from "tslib";
3: import * as path from 'path';
[!] Error: './format' is imported as an external by src\codesandbox.ts, but is already an existing non-external module id.
Error: './format' is imported as an external by src\codesandbox.ts, but is already an existing non-external module id.
    at error (C:\Git\docz.next\docz-utils\node_modules\rollup\dist\rollup.js:3766:30)
    at C:\Git\docz.next\docz-utils\node_modules\rollup\dist\rollup.js:18248:21
    at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:52:5)
    at Function.Module.runMain (internal/modules/cjs/loader.js:871:11)
    at internal/main/run_main_module.js:21:11

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What I'm doing wrong?

@patricksevat
Copy link
Contributor

patricksevat commented Apr 18, 2019

Hi @ejuo I'm encountering the same problem and I'm looking into the same direction as you. I've found that the failed tests are sorta unrelated (they are about snapshots not found and easily fixable), so don't worry about those.

The issue is in docz/core/docz-rollup/src/index.js where on line 8 this fn is defined

const defaultExternal = id =>
  !id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/')

On Unix systems this probably works fine but on Windows not when logging id I get this output:

...
{ id: 'humanize-string' }
{ id: 'lodash/flatten' }
{ id: 'lodash/get' }
{ id: 'C:\\docz\\core\\docz-utils\\src\\format.ts' }
...

I'll try and fix this and create a PR

@ejuo
Copy link
Contributor Author

ejuo commented Apr 18, 2019

Exactly! In general, a rather strange (and dangerous) approach to filter internal/external modules through startsWith.

@patricksevat
Copy link
Contributor

I have limited experience with rollup and its best practices, but I've got it working and submitted a PR, feel free to propose a better solution if you know one.

@ejuo
Copy link
Contributor Author

ejuo commented Apr 20, 2019

I can offer an alternative solution, resolving through the package.json (using rollup-plugin-peer-deps-external):
#821
@patricksevat, @pedronauck, what do you think?

This was referenced Apr 20, 2019
@ejuo
Copy link
Contributor Author

ejuo commented May 6, 2019

@pedronauck
Version 1.1.0 broken again.

Solutions:
#812
#830

@ejuo ejuo reopened this May 6, 2019
@rakannimer rakannimer added v1 v2 windows Windows specific issue labels Sep 8, 2019
@rakannimer rakannimer changed the title Docz v1 not building on Windows Docz not building on Windows Sep 8, 2019
@jesperorb
Copy link

Getting the same error on windows as well. The commit patricksevat@8e0e080 would fix this but it was added as a commit in a larger PR that he closed, but this fix still needs to be applied for v2 to work on Windows. Could you possibly open a PR with just that commit @patricksevat?

@stale
Copy link

stale bot commented Nov 27, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale v1 v2 windows Windows specific issue
Projects
None yet
Development

No branches or pull requests

5 participants