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

Commit

Permalink
Merge branch 'remaxjs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
watsonhaw5566 committed Jan 19, 2022
2 parents e7e54e5 + 7d2e826 commit c02c9e8
Show file tree
Hide file tree
Showing 60 changed files with 406 additions and 101 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

### Bug Fixes

- 修复节点卸载后回调没从 Page 上删除的问题 ([#1822](https://github.com/remaxjs/remax/issues/1822)) ([0a10885](https://github.com/remaxjs/remax/commit/0a1088571d1fc7ad4f5006ee79d81f8814671857)), closes [#1780](https://github.com/remaxjs/remax/issues/1780)

## [2.15.11](https://github.com/remaxjs/remax/compare/v2.15.10...v2.15.11) (2022-01-05)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": false
}
},
"version": "2.15.11",
"version": "2.15.12",
"npmClient": "yarn",
"useWorkspaces": true
}
8 changes: 8 additions & 0 deletions packages/babel-plugin-auto-css-modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

**Note:** Version bump only for package @remax/babel-plugin-auto-css-modules
1 change: 1 addition & 0 deletions packages/babel-plugin-auto-css-modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# `@remax/babel-plugin-auto-css-modules`
4 changes: 4 additions & 0 deletions packages/babel-plugin-auto-css-modules/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
collectCoverageFrom: ['src/**/*.ts'],
};
38 changes: 38 additions & 0 deletions packages/babel-plugin-auto-css-modules/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@remax/babel-plugin-auto-css-modules",
"version": "2.15.12",
"description": "使用真正的 React 构建跨平台小程序",
"authors": [
"chencheng <[email protected]> (https://github.com/sorrycc)"
],
"homepage": "https://remaxjs.org",
"license": "MIT",
"main": "lib/index.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "[email protected]:remaxjs/remax.git"
},
"scripts": {
"clean": "rimraf lib tsconfig.tsbuildinfo",
"prebuild": "npm run clean",
"build": "tsc",
"test": "jest",
"test:debug": "npx --node-arg=--inspect-brk jest -i"
},
"dependencies": {
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@babel/traverse": "^7.11.0",
"@babel/types": "^7.11.0"
},
"devDependencies": {
"@babel/core": "^7.11.0"
},
"gitHead": "14d4b95d916a55e4ecbe5fbda933bbc57018d7df"
}
49 changes: 49 additions & 0 deletions packages/babel-plugin-auto-css-modules/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { transform } from '@babel/core';
import { IOpts } from './index';

function transformWithPlugin(code: string, opts: IOpts) {
const filename = 'file.js';
return transform(code, {
filename,
plugins: [require.resolve('@babel/plugin-syntax-top-level-await'), [require.resolve('../src/index.ts'), opts]],
})!.code;
}

test('css modules', () => {
expect(transformWithPlugin(`import styles from 'a.css';`, {})).toEqual(`import styles from "a.css?modules";`);
expect(transformWithPlugin(`import styles from 'a.less';`, {})).toEqual(`import styles from "a.less?modules";`);
expect(transformWithPlugin(`import styles from 'a.scss';`, {})).toEqual(`import styles from "a.scss?modules";`);
expect(transformWithPlugin(`import styles from 'a.sass';`, {})).toEqual(`import styles from "a.sass?modules";`);
expect(transformWithPlugin(`import styles from 'a.stylus';`, {})).toEqual(`import styles from "a.stylus?modules";`);
expect(transformWithPlugin(`import styles from 'a.styl';`, {})).toEqual(`import styles from "a.styl?modules";`);
});

test('css with top level await', () => {
expect(transformWithPlugin(`const styles = await import('a.css');`, {})).toEqual(
`const styles = await import("a.css?modules");`
);
expect(transformWithPlugin(`await import('a.css');`, {})).toEqual(`await import('a.css');`);
});

test('none css with top level await', () => {
expect(transformWithPlugin(`const styles = await import('a');`, {})).toEqual(`const styles = await import('a');`);
expect(transformWithPlugin(`await import('a');`, {})).toEqual(`await import('a');`);
});

test('css modules with flag', () => {
expect(
transformWithPlugin(`import styles from 'a.css';`, {
flag: 'foo',
})
).toEqual(`import styles from "a.css?foo";`);
});

test('no css modules', () => {
expect(transformWithPlugin(`import 'a.css';`, {})).toEqual(`import 'a.css';`);
});

test('do not infect non css imports', () => {
expect(transformWithPlugin(`import a from 'a';`, {})).toEqual(`import a from 'a';`);
expect(transformWithPlugin(`import a from 'a.js';`, {})).toEqual(`import a from 'a.js';`);
expect(transformWithPlugin(`import 'a';`, {})).toEqual(`import 'a';`);
});
42 changes: 42 additions & 0 deletions packages/babel-plugin-auto-css-modules/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { extname } from 'path';
import * as t from '@babel/types';
import { NodePath } from '@babel/traverse';

export interface IOpts {
flag?: string;
}

const CSS_EXT_NAMES = ['.css', '.less', '.sass', '.scss', '.stylus', '.styl'];

export default function () {
return {
visitor: {
ImportDeclaration(path: NodePath<t.ImportDeclaration>, { opts }: { opts: IOpts }) {
const {
specifiers,
source,
source: { value },
} = path.node;
if (specifiers.length && CSS_EXT_NAMES.includes(extname(value))) {
source.value = `${value}?${opts.flag || 'modules'}`;
}
},

// e.g.
// const styles = await import('./index.less');
VariableDeclarator(path: NodePath<t.VariableDeclarator>, { opts }: { opts: IOpts }) {
const { node } = path;
if (
t.isAwaitExpression(node.init) &&
t.isCallExpression(node.init.argument) &&
t.isImport(node.init.argument.callee) &&
node.init.argument.arguments.length === 1 &&
t.isStringLiteral(node.init.argument.arguments[0]) &&
CSS_EXT_NAMES.includes(extname(node.init.argument.arguments[0].value))
) {
node.init.argument.arguments[0].value = `${node.init.argument.arguments[0].value}?${opts.flag || 'modules'}`;
}
},
},
};
}
16 changes: 16 additions & 0 deletions packages/babel-plugin-auto-css-modules/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"target": "ES2017",
"declaration": true,
"rootDir": "src",
"outDir": "lib",
"types": ["@types/jest", "@types/node"],
"jsx": "preserve",
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["src", "typings"],
"exclude": ["tests", "lib"],
}
4 changes: 4 additions & 0 deletions packages/babel-plugin-remax-host-component/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

**Note:** Version bump only for package babel-plugin-remax-host-component

## [2.15.11](https://github.com/remaxjs/remax/compare/v2.15.10...v2.15.11) (2022-01-05)

**Note:** Version bump only for package babel-plugin-remax-host-component
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-plugin-remax-host-component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-remax-host-component",
"version": "2.15.11",
"version": "2.15.12",
"description": "使用真正的 React 构建跨平台小程序",
"author": "Wei Zhu <[email protected]>",
"homepage": "https://remaxjs.org",
Expand Down Expand Up @@ -28,13 +28,13 @@
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/traverse": "^7.11.0",
"@babel/types": "^7.11.0",
"@remax/macro": "2.15.11",
"@remax/shared": "2.15.11"
"@remax/macro": "2.15.12",
"@remax/shared": "2.15.12"
},
"devDependencies": {
"@babel/core": "^7.11.0",
"@babel/plugin-syntax-jsx": "^7.10.4",
"@remax/build-store": "2.15.11"
"@remax/build-store": "2.15.12"
},
"gitHead": "14d4b95d916a55e4ecbe5fbda933bbc57018d7df"
}
4 changes: 4 additions & 0 deletions packages/babel-plugin-remax-lifecycle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

**Note:** Version bump only for package babel-plugin-remax-lifecycle

## [2.15.11](https://github.com/remaxjs/remax/compare/v2.15.10...v2.15.11) (2022-01-05)

**Note:** Version bump only for package babel-plugin-remax-lifecycle
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-plugin-remax-lifecycle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-remax-lifecycle",
"version": "2.15.11",
"version": "2.15.12",
"description": "使用真正的 React 构建跨平台小程序",
"author": "Wei Zhu <[email protected]>",
"homepage": "https://remaxjs.org",
Expand Down Expand Up @@ -28,11 +28,11 @@
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/traverse": "^7.11.0",
"@babel/types": "^7.11.0",
"@remax/shared": "2.15.11"
"@remax/shared": "2.15.12"
},
"devDependencies": {
"@babel/core": "^7.11.0",
"@remax/build-store": "2.15.11"
"@remax/build-store": "2.15.12"
},
"gitHead": "14d4b95d916a55e4ecbe5fbda933bbc57018d7df"
}
4 changes: 4 additions & 0 deletions packages/babel-plugin-remax-regenerator-runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

**Note:** Version bump only for package babel-plugin-remax-regenerator-runtime

## [2.15.11](https://github.com/remaxjs/remax/compare/v2.15.10...v2.15.11) (2022-01-05)

**Note:** Version bump only for package babel-plugin-remax-regenerator-runtime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-remax-regenerator-runtime",
"version": "2.15.11",
"version": "2.15.12",
"description": "使用真正的 React 构建跨平台小程序",
"author": "Wei Zhu <[email protected]>",
"homepage": "https://remaxjs.org",
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-plugin-remax-turbo-render/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

**Note:** Version bump only for package babel-plugin-remax-turbo-render

## [2.15.11](https://github.com/remaxjs/remax/compare/v2.15.10...v2.15.11) (2022-01-05)

**Note:** Version bump only for package babel-plugin-remax-turbo-render
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-remax-turbo-render/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-remax-turbo-render",
"version": "2.15.11",
"version": "2.15.12",
"description": "使用真正的 React 构建跨平台小程序",
"author": "Wei Zhu <[email protected]>",
"homepage": "https://remaxjs.org",
Expand Down Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@babel/core": "^7.11.0",
"@remax/build-store": "2.15.11",
"@remax/build-store": "2.15.12",
"@types/jest": "^26.0.8",
"babel-plugin-tester": "^9.2.0"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-preset-remax/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

**Note:** Version bump only for package babel-preset-remax

## [2.15.11](https://github.com/remaxjs/remax/compare/v2.15.10...v2.15.11) (2022-01-05)

**Note:** Version bump only for package babel-preset-remax
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-preset-remax/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-remax",
"version": "2.15.11",
"version": "2.15.12",
"description": "remax babel preset",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -31,7 +31,7 @@
"@babel/preset-env": "^7.7.4",
"@babel/preset-react": "^7.7.4",
"@babel/preset-typescript": "^7.7.4",
"@umijs/babel-plugin-auto-css-modules": "^3.3.1",
"@remax/babel-plugin-auto-css-modules": "2.15.12",
"babel-plugin-auto-import": "^1.0.5",
"babel-plugin-macros": "^3.1.0",
"lodash": "^4.17.15"
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-remax/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function preset(api: any, presetOption: PresetOption) {
declarations: [{ default: 'regeneratorRuntime', path: 'regenerator-runtime' }],
},
],
require.resolve('@umijs/babel-plugin-auto-css-modules'),
require.resolve('@remax/babel-plugin-auto-css-modules'),
],
};
}
Expand Down
4 changes: 4 additions & 0 deletions packages/postcss-remax-tag/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

**Note:** Version bump only for package @remax/postcss-tag

## [2.15.11](https://github.com/remaxjs/remax/compare/v2.15.10...v2.15.11) (2022-01-05)

**Note:** Version bump only for package @remax/postcss-tag
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-remax-tag/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remax/postcss-tag",
"version": "2.15.11",
"version": "2.15.12",
"main": "index.js",
"repository": "[email protected]:remaxjs/remax.git",
"author": "Caihuanyu <[email protected]>",
Expand Down
4 changes: 4 additions & 0 deletions packages/remax-ali/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.15.12](https://github.com/remaxjs/remax/compare/v2.15.11...v2.15.12) (2022-01-11)

**Note:** Version bump only for package @remax/ali

## [2.15.11](https://github.com/remaxjs/remax/compare/v2.15.10...v2.15.11) (2022-01-05)

**Note:** Version bump only for package @remax/ali
Expand Down
6 changes: 3 additions & 3 deletions packages/remax-ali/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remax/ali",
"version": "2.15.11",
"version": "2.15.12",
"description": "Remax for Ali",
"main": "./cjs/index.js",
"esnext": "./esm/index.js",
Expand All @@ -16,11 +16,11 @@
"repository": "git+https://github.com/remaxjs/remax.git",
"license": "MIT",
"dependencies": {
"@remax/shared": "2.15.11",
"@remax/shared": "2.15.12",
"mini-types": "^0.1.1"
},
"devDependencies": {
"@remax/types": "2.15.11",
"@remax/types": "2.15.12",
"@types/react": "^16.9.33",
"@types/react-test-renderer": "^16.9.1",
"react": "^16.12.0",
Expand Down
Loading

0 comments on commit c02c9e8

Please sign in to comment.