Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
chore(cli): update rollup plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Darmody committed Nov 7, 2019
1 parent 1f93d18 commit 8e59eee
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 31 deletions.
4 changes: 2 additions & 2 deletions packages/remax-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"@remax/postcss-px2units": "^0.2.0",
"@remax/rollup-plugin-postcss": "^2.0.4",
"@remax/rollup-plugin-url": "^3.0.1",
"@rollup/plugin-alias": "^2.2.0",
"@rollup/plugin-replace": "^2.2.1",
"acorn-jsx": "^5.1.0",
"acorn-walk": "^7.0.0",
"babel-preset-remax": "^1.3.1",
Expand All @@ -60,7 +62,6 @@
"remax": "^1.3.1",
"resolve": "^1.12.0",
"rollup": "^1.21.3",
"rollup-plugin-alias": "^1.5.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-clear": "^2.0.7",
"rollup-plugin-commonjs": "^10.0.0",
Expand All @@ -70,7 +71,6 @@
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.0.3",
"rollup-plugin-progress": "^1.1.1",
"rollup-plugin-replace": "^2.2.0",
"slash2": "^2.0.0",
"yargs": "^13.2.4"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/node_modules/rollup/dist/rollup.js b/node_modules/rollup/dist/rollup.js
index 364c40d..35e3e3e 100644
index 041c9f6..f5ab82c 100644
--- a/node_modules/rollup/dist/rollup.js
+++ b/node_modules/rollup/dist/rollup.js
@@ -13445,7 +13445,7 @@ function rollup(rawInputOptions) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<view>d</view>
<view>e</view>
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@



<template name="REMAX_TPL_1_complex-4">
<complex-4 >
<template name="REMAX_TPL_1_complex-5">
<complex-5 >

<block a:for="{{item.children}}" key="{{item.id}}">
<block a:if="{{item.props['slot']}}" >
Expand All @@ -144,7 +144,7 @@
</block>
</block>

</complex-4>
</complex-5>
</template>


Expand Down Expand Up @@ -211,6 +211,28 @@



<template name="REMAX_TPL_1_e-4">
<e-4 >

<block a:for="{{item.children}}" key="{{item.id}}">
<block a:if="{{item.props['slot']}}" >
<view disable-scroll="{{item.props['disable-scroll']}}" hover-class="{{item.props['hover-class']}}" hover-start-time="{{item.props['hover-start-time']}}" hover-stay-time="{{item.props['hover-stay-time']}}" hidden="{{item.props['hidden']}}" class="{{item.props['class']}}" style="{{item.props['style']}}" animation="{{item.props['animation']}}" hover-stop-propagation="{{item.props['hover-stop-propagation']}}" onTap="{{item.props['onTap']}}" catchTap="{{item.props['catchTap']}}" onTouchStart="{{item.props['onTouchStart']}}" onTouchMove="{{item.props['onTouchMove']}}" onTouchEnd="{{item.props['onTouchEnd']}}" onTouchCancel="{{item.props['onTouchCancel']}}" onLongTap="{{item.props['onLongTap']}}" onTransitionEnd="{{item.props['onTransitionEnd']}}" onAnimationIteration="{{item.props['onAnimationIteration']}}" onAnimationStart="{{item.props['onAnimationStart']}}" onAnimationEnd="{{item.props['onAnimationEnd']}}" onAppear="{{item.props['onAppear']}}" onDisappear="{{item.props['onDisappear']}}" onFirstAppear="{{item.props['onFirstAppear']}}" >
<block a:for="{{item.children}}" key="{{item.id}}">
<template is="REMAX_TPL_1_CONTAINER" data="{{item: item}}" />
</block>
</view>
</block>
<block a:else>
<template is="REMAX_TPL_1_CONTAINER" data="{{item: item}}" />
</block>
</block>

</e-4>
</template>




<template name="REMAX_TPL_1_form">
<form class="{{item.props['class']}}" style="{{item.props['style']}}" report-submit="{{item.props['report-submit']}}" onSubmit="{{item.props['onSubmit']}}" onReset="{{item.props['onReset']}}" >

Expand Down Expand Up @@ -328,8 +350,8 @@



<template name="REMAX_TPL_1_my-plugin-5">
<my-plugin-5 >
<template name="REMAX_TPL_1_my-plugin-6">
<my-plugin-6 >

<block a:for="{{item.children}}" key="{{item.id}}">
<block a:if="{{item.props['slot']}}" >
Expand All @@ -344,14 +366,14 @@
</block>
</block>

</my-plugin-5>
</my-plugin-6>
</template>




<template name="REMAX_TPL_1_my-plugin-6">
<my-plugin-6 >
<template name="REMAX_TPL_1_my-plugin-7">
<my-plugin-7 >

<block a:for="{{item.children}}" key="{{item.id}}">
<block a:if="{{item.props['slot']}}" >
Expand All @@ -366,7 +388,7 @@
</block>
</block>

</my-plugin-6>
</my-plugin-7>
</template>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import '../npm/remax/esm/adapters/alipay/components/ContactButton.js';
import '../npm/remax/esm/adapters/alipay/api.js';

var _page = function _page() {
return createElement(View, null, createElement(A, null), createElement(B, null), createElement(C, null), createElement(D, null), createElement(Complex, null), createElement(PluginComponent, null), createElement(PluginComponent2, null));
return createElement(View, null, createElement(A, null), createElement(B, null), createElement(C, null), createElement(D, null), createElement(E, null), createElement(Complex, null), createElement(PluginComponent, null), createElement(PluginComponent2, null));
};

var index = Page(createPageConfig(_page));var A = function(props) {
Expand All @@ -68,21 +68,27 @@ var index = Page(createPageConfig(_page));var A = function(props) {
propsAlias(props, true),
props.children
);
};var E = function(props) {
return createElement(
'e-4',
propsAlias(props, true),
props.children
);
};var Complex = function(props) {
return createElement(
'complex-4',
'complex-5',
propsAlias(props, true),
props.children
);
};var PluginComponent = function(props) {
return createElement(
'my-plugin-5',
'my-plugin-6',
propsAlias(props, true),
props.children
);
};var PluginComponent2 = function(props) {
return createElement(
'my-plugin-6',
'my-plugin-7',
propsAlias(props, true),
props.children
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"b-1": "../components/b/index",
"c-2": "../components/c/index",
"d-3": "../components/d/index",
"complex-4": "../components/complex/index",
"my-plugin-5": "plugin:https://myPlugin/xx",
"my-plugin-6": "plugin:https://myPlugin/dddd"
"e-4": "../components/e/index",
"complex-5": "../components/complex/index",
"my-plugin-6": "plugin:https://myPlugin/xx",
"my-plugin-7": "plugin:https://myPlugin/dddd"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<view>d</view>
<view>e</view>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { View } from 'remax/alipay';
import A from '../components/a';
import B from '@/components/b';
import C from '../components/c/index';
import D from '../components/d/index.js';
import D from '@c/d/index.js';
import E from '@components/e/index.js';
import Complex from '../components/complex';
import PluginComponent from 'plugin:https://myPlugin/xx';
import PluginComponent2 from 'plugin:https://myPlugin/dddd';
Expand All @@ -14,6 +15,7 @@ export default () => (
<B />
<C />
<D />
<E />
<Complex />
<PluginComponent />
<PluginComponent2 />
Expand Down
2 changes: 2 additions & 0 deletions packages/remax-cli/src/__tests__/helpers/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default async function build(app: string, target: string) {
},
alias: {
'@': 'src',
'@components': 'src/components',
'@c': path.resolve(cwd, 'src/components'),
},
},
false,
Expand Down
22 changes: 15 additions & 7 deletions packages/remax-cli/src/build/plugins/alias.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import * as path from 'path';
import aliasPlugin from 'rollup-plugin-alias';
import aliasPlugin from '@rollup/plugin-alias';
import { RemaxOptions } from '../../getConfig';

export default function(options: RemaxOptions) {
const aliasConfig = Object.entries(options.alias || {}).reduce(
(config, [key, value]) => {
config[key] = value.match(/^(\.|[^/])/)
? path.resolve(options.cwd, value)
: value;
config.push({
find: key,
replacement: value.match(/^(\.|[^/])/)
? path.resolve(options.cwd, value)
: value,
});
return config;
},
{} as any
[] as any[]
);
return aliasPlugin({
resolve: [
Expand All @@ -24,7 +27,12 @@ export default function(options: RemaxOptions) {
'/index.ts',
'/index.tsx',
],
'@': path.resolve(options.cwd, options.rootDir),
...aliasConfig,
entries: [
{
find: '@',
replacement: path.resolve(options.cwd, options.rootDir),
},
...aliasConfig,
],
});
}
2 changes: 1 addition & 1 deletion packages/remax-cli/src/build/rollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import page from './plugins/page';
import removeSrc from './plugins/removeSrc';
import removeConfig from './plugins/removeConfig';
import rename from './plugins/rename';
import replace from 'rollup-plugin-replace';
import replace from '@rollup/plugin-replace';
import { RemaxOptions } from '../getConfig';
import app from './plugins/app';
import removeESModuleFlag from './plugins/removeESModuleFlag';
Expand Down
2 changes: 1 addition & 1 deletion packages/remax-cli/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare module 'rollup-plugin-json';
declare module 'rollup-plugin-node-resolve';
declare module 'rollup-plugin-progress';
declare module 'rollup-plugin-delete';
declare module 'rollup-plugin-alias';
declare module '@rollup/plugin-alias';
declare module 'rollup-plugin-inject';
declare module '@remax/rollup-plugin-url';
declare module 'rollup-plugin-typescript';
Expand Down

1 comment on commit 8e59eee

@vercel
Copy link

@vercel vercel bot commented on 8e59eee Nov 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.