This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'remaxjs:master' into master
- Loading branch information
Showing
60 changed files
with
406 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"private": false | ||
} | ||
}, | ||
"version": "2.15.11", | ||
"version": "2.15.12", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# `@remax/babel-plugin-auto-css-modules` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
collectCoverageFrom: ['src/**/*.ts'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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';`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'}`; | ||
} | ||
}, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
@@ -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" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.