babel-plugin-markdown-in-jsx
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -0,0 +0,0 @@ import * as React from "react"; |
module.exports = props => props.children; | ||
module.exports.default = props => props.children; |
@@ -0,0 +0,0 @@ import * as React from "react"; |
@@ -0,0 +0,0 @@ const React = require('react'); |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** @preserve |
@@ -0,0 +0,0 @@ /** |
10
index.js
@@ -177,4 +177,4 @@ const _ = require('lodash'); | ||
} | ||
const ProgramPath = jsxIdentifierPath.findParent(babelTypes.isProgram); | ||
if (state.commonjs) { | ||
const ProgramPath = jsxIdentifierPath.findParent(babelTypes.isProgram); | ||
ProgramPath.unshiftContainer('body', | ||
@@ -189,2 +189,10 @@ babelTypes.variableDeclaration('var', [ | ||
state.proxyContextName = declaratorName; | ||
} else { | ||
ProgramPath.unshiftContainer('body', | ||
babelTypes.importDeclaration( | ||
[babelTypes.importNamespaceSpecifier(babelTypes.identifier(declaratorName))], | ||
babelTypes.stringLiteral(join(options.package, 'component/proxy')) | ||
) | ||
); | ||
state.proxyContextName = declaratorName; | ||
} | ||
@@ -191,0 +199,0 @@ } |
{ | ||
"name": "babel-plugin-markdown-in-jsx", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Transform Markdown inside JSX to DOM elements at compile time.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -91,3 +91,3 @@ # babel-plugin-markdown-in-jsx | ||
``` html | ||
``` js | ||
<Markdown> | ||
@@ -140,5 +140,5 @@ 123 | ||
比如要替换文中所有的 `<img />` 和 `<h1 />` | ||
比如要替换文中所有的 `<img />` 和 `<h1 />` | ||
``` html | ||
``` js | ||
<Proxy.Provider | ||
@@ -154,5 +154,5 @@ value={{ | ||
`<Proxy.Provider />` 下面的所有 `<Markdown />` 都会被设置影响。 | ||
`<Proxy.Provider />` 下面的所有 `<Markdown />` 都会被设置影响。 | ||
下面是一个为所有的图片增加红色边框的例子。 | ||
下面是一个为所有的图片增加红色边框的例子。 | ||
@@ -159,0 +159,0 @@ ``` js |
@@ -63,3 +63,3 @@ const babel = require('@babel/core'); | ||
const code = babel.transform(renderBody, { | ||
presets: [babelEnv, babelReact], | ||
presets: [babelReact], | ||
plugins: [[plugin, {package: 'Markdown'}]] | ||
@@ -153,1 +153,24 @@ }).code | ||
}); | ||
test('transform to html with proxy esmodules', () => { | ||
const renderBody = `import * as React from 'react'; | ||
import Markdown from 'Markdown/component'; | ||
function TestComponent() { | ||
return ( | ||
<Markdown> | ||
# Title | ||
This is **bold.** | ||
Here is a [link](/some/url). | ||
</Markdown> | ||
) | ||
}`; | ||
const code = babel.transform(renderBody, { | ||
presets: [babelReact], | ||
plugins: [[plugin, {package: 'Markdown', proxy: true}]] | ||
}).code | ||
expect(code).toMatchSnapshot(); | ||
}); |
@@ -0,0 +0,0 @@ const React = require('react'); |
@@ -0,0 +0,0 @@ const React = require('react'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
343665
1894