typewriter-editor / typewriter

A rich text editor based off of Quill.js and Ultradom, and using Svelte for UI.
MIT License
382 stars 32 forks source link

Client project Webpack imports failing on 0.6.45 – hash 777a47d #101

Closed taylorhadden closed 2 years ago

taylorhadden commented 2 years ago

After updating my local repo of typewriter-editor to 777a47d, my project using Typewriter is failing to build.

I'm getting dozens (hundreds? It overflows my console) of messages that look like this:

ModuleDependencyWarning: export 'Delta' (imported as 'Delta') was not found in 'typewriter-editor' (possible exports: diff)

The built files for typewriter in my local repository look correct for an ES Module.

import cloneDeep from './util/cloneDeep';
import intersect from './util/intersect';
import isEqual from './util/isEqual';
import diff from 'fast-diff';
import EventDispatcher from './util/EventDispatcher';
export { cloneDeep, intersect, isEqual, diff, EventDispatcher };
import AttributeMap from './delta/AttributeMap';
import Delta from './delta/Delta';
import Op, { OpIterator } from './delta/Op';
export { AttributeMap, Delta, Op, OpIterator };
export * from './doc/EditorRange';
export * from './doc/deltaToText';
import Line, { LineIterator } from './doc/Line';
import LineOp, { LineOpIterator } from './doc/LineOp';
import TextChange from './doc/TextChange';
import TextDocument from './doc/TextDocument';
export { Line, LineIterator, LineOp, LineOpIterator, TextChange as TextChange, TextDocument as TextDocument };
export * from './rendering/vdom';
export * from './typesetting/typeset';
export * from './rendering/position';
export * from './rendering/selection';
export * from './rendering/rendering';
export * from './rendering/html';
export * from './modules';
export * from './stores';
export * from './typesetting/defaults';
export * from './Source';
export * from './Editor';
import Editor from './Editor';
export { Editor };
//# sourceMappingURL=index.js.map

Am I just being a dummy and not configuring my project's Webpack to correctly load typewriter now that it's distributed as an ES2015 package?

jacwright commented 2 years ago

I has some issues with latest Webpack as well and finally got them resolved using:

    rules: [
      {
        test: /\.js$/,
        use: 'source-map-loader',
        resolve: { fullySpecified: false }
      },
      {
        test: /\.ts$/,
        exclude: /node_modules/,
        use: [{
          loader: 'ts-loader',
          options: { onlyCompileBundledFiles: true }
        }],
      },

I didn't understand how it helped, but fullySpecified and onlyCompileBundledFiles seemed to be important.

Does this help?

jacwright commented 2 years ago

I'm really unhappy with the current state of bundlers. It seems there are issues with anything you use. I favored webpack over rollup because it worked with pretty much all modules and handles recursive imports, where rollup seemed to give me strife with every single project I tried to use it on. Now webpack does the same.

taylorhadden commented 2 years ago

Thanks for the update; sorry for the long delay. I will check up on this soon.

taylorhadden commented 2 years ago

"Soon" turned out to be relative; however, you're post was helpful.

I ended up using:

{
    test: /\.js$/,
    resolve: { fullySpecified: false }
}

And this solved my "path must be fully specified" problems.


I also very much agree regarding bundlers. I spent the last two days trying to get a Vite build working on Tangent, but esbuild seems to be choking on export * from '@typewriter/delta' and similar.

Seems like there is an open issue in esbuild for this... evanw/esbuild#1737