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

Can't run prosemirror-transform tests #1108

Closed
Narretz opened this issue Nov 30, 2020 · 9 comments
Closed

Can't run prosemirror-transform tests #1108

Narretz opened this issue Nov 30, 2020 · 9 comments

Comments

@Narretz
Copy link

Narretz commented Nov 30, 2020

Issue details

Steps to reproduce

  1. checkout prosemirror-transform
  2. run npm install
  3. run npm run test
  4. Get the following error:
> prosemirror-transform@1.2.8 test C:\Users\user\prosemirror-transform
> mocha test/test-*.js

internal/modules/cjs/loader.js:834
  throw err;
  ^

Error: Cannot find module './transform.js'
Require stack:
- C:\Users\Martin\dev\prosemirror-transform\dist\index.js
- C:\Users\Martin\dev\prosemirror-transform\test\test-mapping.js
- C:\Users\Martin\dev\prosemirror-transform\node_modules\mocha\lib\mocha.js
- C:\Users\Martin\dev\prosemirror-transform\node_modules\mocha\index.js
- C:\Users\Martin\dev\prosemirror-transform\node_modules\mocha\bin\_mocha
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\Martin\dev\prosemirror-transform\dist\index.js:5:20)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\Martin\dev\prosemirror-transform\test\test-mapping.js:2:28)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at C:\Users\Martin\dev\prosemirror-transform\node_modules\mocha\lib\mocha.js:231:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (C:\Users\Martin\dev\prosemirror-transform\node_modules\mocha\lib\mocha.js:228:14)
    at Mocha.run (C:\Users\Martin\dev\prosemirror-transform\node_modules\mocha\lib\mocha.js:514:10)
    at Object.<anonymous> (C:\Users\Martin\dev\prosemirror-transform\node_modules\mocha\bin\_mocha:480:18)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Martin\\dev\\prosemirror-transform\\dist\\index.js',
    'C:\\Users\\Martin\\dev\\prosemirror-transform\\test\\test-mapping.js',
    'C:\\Users\\Martin\\dev\\prosemirror-transform\\node_modules\\mocha\\lib\\mocha.js',
    'C:\\Users\\Martin\\dev\\prosemirror-transform\\node_modules\\mocha\\index.js',
    'C:\\Users\\Martin\\dev\\prosemirror-transform\\node_modules\\mocha\\bin\\_mocha'
  ]
}

ProseMirror version

prosemirror-transform#master, prosemirror-transform#1.2.8

Since this seems to be a module resolution problem, other prosemirror packages might be affected to.

Or is developing single packages not supported anymore and I have to setup a dev env via the main prosemirror repo?

@marijnh
Copy link
Member

marijnh commented Dec 1, 2020

I can't reproduce this (node 14.0, npm 6.14.8, on Linux). Which node and npm versions are you using? dist/index.js should definitely not be requiring and ./ paths... if it is, something went wrong in the build.

@Narretz
Copy link
Author

Narretz commented Dec 1, 2020

I'm on node v12.19.0 and npm 6.14.8.

The start of my dist/index.js looks like this:

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var transform_js = require('./transform.js');
var step_js = require('./step.js');
var structure_js = require('./structure.js');
var map_js = require('./map.js');
var mark_step_js = require('./mark_step.js');
var replace_step_js = require('./replace_step.js');
require('./mark.js');
var replace_js = require('./replace.js');

@marijnh
Copy link
Member

marijnh commented Dec 1, 2020

Looks like Rollup treated the internal imports as external for some reason. I can't really explain why it would be doing that, through. Which version of rollup did you get when installing?

@Narretz
Copy link
Author

Narretz commented Dec 1, 2020

rollup is 2.34.0
rollup-plugin-buble is 0.21.3

Have you considered adding a package-lock.json to lock the dependencies to known good versions?

I will try again with the versions before ProseMirror/prosemirror-transform@c3bbb16 but I think I did already with same result

edit: Yes, I get the same results with the previous rollup versions.

So it can be because of

  • node version
  • Windows

@marijnh
Copy link
Member

marijnh commented Dec 1, 2020

I get the same rollup version, so that's not it either.

It could be because of windows, yes. Taking a second look at the rollup.config.js that seems very likely. If you add \\ to the bracketed character group in the external option, does that help?

@Narretz
Copy link
Author

Narretz commented Dec 1, 2020

It's Windows (I should have known, it's always Windows and the path handling ;)).
See this comment in rollup repo: rollup/rollup#3811 (comment)

If I change the config accordingly, it works:

const path = require('path');

module.exports = {
  input: './src/index.js',
  ...
  external(id) {
    return !/^[\.\/]/.test(id) && !path.isAbsolute(id)
  }
}
```

@marijnh
Copy link
Member

marijnh commented Dec 1, 2020

Ah, right, just adding a backslash wouldn't do it either. I'll go ahead and adjust all the rollup config files

@Narretz
Copy link
Author

Narretz commented Dec 1, 2020

Thanks @marijnh for the quick response!

marijnh added a commit to ProseMirror/prosemirror-model that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-transform that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-state that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-view that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-keymap that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-inputrules that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-history that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-collab that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-commands that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-gapcursor that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-schema-basic that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-schema-list that referenced this issue Dec 1, 2020
@marijnh
Copy link
Member

marijnh commented Dec 1, 2020

Pulling that patch and rebuilding should fix this.

@marijnh marijnh closed this as completed Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-menu that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-example-setup that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-markdown that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-dropcursor that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-test-builder that referenced this issue Dec 1, 2020
marijnh added a commit to ProseMirror/prosemirror-changeset that referenced this issue Dec 1, 2020
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

No branches or pull requests

2 participants