Giter Site home page Giter Site logo

yozorajs / yozora Goto Github PK

View Code? Open in Web Editor NEW
145.0 4.0 2.0 43.96 MB

A customizable markup parser for resolving markdown-like syntax strings into AST and vice versa.

Home Page: https://yozora.guanghechen.com

License: MIT License

JavaScript 2.50% TypeScript 93.35% Handlebars 4.15%
gfm markdown-parser markdown mdast yozora markdown-ast

yozora's Issues

CJS lib issue "TypeError: invariant is not a function"

When you try and use the DefaultParser from @yozora/core-parser using the cjs lib you get the following error:

TypeError: invariant is not a function
    at consumeNewOpener (https://cigod8.csb.app/node_modules/@yozora/core-parser/lib/cjs/index.cjs:143:13)
    at Object.consume (https://cigod8.csb.app/node_modules/@yozora/core-parser/lib/cjs/index.cjs:303:13)
    at matchBlockTokens (https://cigod8.csb.app/node_modules/@yozora/core-parser/lib/cjs/index.cjs:793:27)
    at Object.process (https://cigod8.csb.app/node_modules/@yozora/core-parser/lib/cjs/index.cjs:736:32)
    at CustomParser.parse (https://cigod8.csb.app/node_modules/@yozora/core-parser/lib/cjs/index.cjs:975:32)
    at Object.eval (https://cigod8.csb.app/src/CustomParser.test.ts:15:25)
    at https://codesandbox.io/static/js/3.09a963795.chunk.js:1:338381
    at new Promise (<anonymous>)
    at t.callAsyncFn (https://codesandbox.io/static/js/3.09a963795.chunk.js:1:338040)
    at https://codesandbox.io/static/js/7.916d1bd34.chunk.js:1:6522
    at c (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.7424373eb.chunk.js:1:4328)

Here is a code sandbox for the problem:
https://codesandbox.io/s/delicate-haze-cigod8?file=/index.html

The @yozora/invariant/lib/cjs/index.cjs looks like:

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });
...
function invariant(condition, message) {
    ...
}

exports.default = invariant;
exports.invariant = invariant;

which comes from https://github.com/yozorajs/yozora/blob/main/packages/invariant/src/index.ts

export function invariant(
  condition: boolean,
  message?: string | (() => string),
): asserts condition {
  ...
}

export default invariant

The problem occurs when @yozora/core-parse/lib/cjs/index.cjs requires the @yozora/invariant', expecting the default to be the invariant function.

var invariant = require('@yozora/invariant');

But for this to work it would need to use the default:

var invariant = require('@yozora/invariant').default;

I am no rollup expert but I think it may be something to do with this issue: rollup/rollup#1961

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.