Closed bradleyayers closed 1 year ago
Are you applying patches to the build output, or why is this a problem for you?
The ESM output doesn't use Babel, by the way, and might be more stable.
Yes we have patches that apply to the build output, as we a number of runtime behavior changes in our patches.
Unfortunately we need CJS support, so we have to patch those.
I've tried a couple of workflows:
yarn patch prosemirror-view
src/…
npm install
yarn patch-commit -s …
This is pretty simple but doens't produce min-diff outputs.
I then just tried cloning the repo and building from that, and had similar results.
At first the problem I was having was just "verbose diff", but for some other packages (e.g. prosemirror-markdown) I actually get broken output, e.g.
function tokenHandlers(schema, tokens) {
var handlers = Object.create(null);
-
- var _loop = function _loop(type) {
+ var _loop = function _loop() {
var spec = tokens[type];
-
if (spec.block) {
var nodeType = schema.nodeType(spec.block);
-
if (noCloseToken(spec, type)) {
handlers[type] = function (state, tok, tokens, i) {
state.openNode(nodeType, attrs(spec, tok, tokens, i));
@@ -438,20 +412,17 @@ function tokenHandlers(schema, tokens) {
handlers[type + "_open"] = function (state, tok, tokens, i) {
return state.openNode(nodeType, attrs(spec, tok, tokens, i));
};
-
handlers[type + "_close"] = function (state) {
return state.closeNode();
};
}
} else if (spec.node) {
var _nodeType = schema.nodeType(spec.node);
-
handlers[type] = function (state, tok, tokens, i) {
return state.addNode(_nodeType, attrs(spec, tok, tokens, i));
};
} else if (spec.mark) {
var markType = schema.marks[spec.mark];
-
if (noCloseToken(spec, type)) {
handlers[type] = function (state, tok, tokens, i) {
state.openMark(markType.create(attrs(spec, tok, tokens, i)));
@@ -462,7 +433,6 @@ function tokenHandlers(schema, tokens) {
handlers[type + "_open"] = function (state, tok, tokens, i) {
return state.openMark(markType.create(attrs(spec, tok, tokens, i)));
};
-
handlers[type + "_close"] = function (state) {
return state.closeMark(markType);
};
@@ -478,63 +448,47 @@ function tokenHandlers(schema, tokens) {
throw new RangeError("Unrecognized parsing spec " + JSON.stringify(spec));
}
};
-
for (var type in tokens) {
- _loop(type);
+ _loop();
}
This looks really broken, like type
is used…
So at this point I can either manually patch the build outputs, or try to figure out what version of dependencies will produce the right outputs.
Patching build output is a rather unconventional thing to do, and not something this library provides any guarantees for, sorry. Seems like applying the patches to the input sources and running the build process on the result would work better.
Ah I think I might have misunderstood the question. Yes I'm patching input sources (i.e. Make changes to src/…
), running the build process (npm install
which in turn runs npm run prepare
which in turn runs pm-buildhelper
), and then I'm seeing large diffs in the build output.
I'm then saving a patch of the build output (this is how yarn patch
and patch-package
work). Unless I'm misunderstanding something if you git clone
prosemirror-markdown and run npm install
, you'll see corrupted outputs in dist/
too.
I see. But this really is a problem that I consider out of scope from what the library guarantees.
I guess I found it surprising that cloning prosemirror-markdown and running npm install
-> npm prepare
produces broken dist/
, but if it's working for you fair enough.
Thanks for the consideration and quick replies.
I'm in the process of upgrading to the latest version of prosemirror-* packages, and need to migrate some of our patches across. However I'm finding that when running the
prepare
NPM script the output dist is quite different from the code in the published NPM packages.e.g. from prosemirror-view
I'm guessing there are transitive dependencies that have upgraded in the background. Perhaps including a
package-lock.json
in the repo would help in this scenario.