@modern-js/plugin-tailwindcss 1.2.0 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @modern-js/plugin-tailwindcss
2
2
 
3
+ ## 1.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 8f24a514: fix: UserConfig is missing tools.tailwindcss type
8
+ - Updated dependencies [deeaa602]
9
+ - Updated dependencies [54786e58]
10
+ - @modern-js/utils@1.3.2
11
+ - @modern-js/core@1.4.3
12
+
13
+ ## 1.2.2
14
+
15
+ ### Patch Changes
16
+
17
+ - 6891e4c2: add @modern-js/plugin-design-token, support 'source.designSystem.supportStyledComponents' config
18
+ - Updated dependencies [6891e4c2]
19
+ - Updated dependencies [b376c8d6]
20
+ - Updated dependencies [e62c4efd]
21
+ - Updated dependencies [e2a8233f]
22
+ - @modern-js/plugin-design-token@1.0.1
23
+ - @modern-js/core@1.4.2
24
+
25
+ ## 1.2.1
26
+
27
+ ### Patch Changes
28
+
29
+ - 83166714: change .npmignore
30
+ - Updated dependencies [83166714]
31
+ - Updated dependencies [c3de9882]
32
+ - Updated dependencies [33ff48af]
33
+ - @modern-js/core@1.3.2
34
+ - @modern-js/utils@1.2.2
35
+
3
36
  ## 1.2.0
4
37
 
5
38
  ### Minor Changes
@@ -9,7 +9,10 @@ var _utils = require("@modern-js/utils");
9
9
 
10
10
  var _tailwind = require("./tailwind");
11
11
 
12
- const core = _utils.Import.lazy('@modern-js/core', require);
12
+ const core = _utils.Import.lazy('@modern-js/core', require); // support designSystem.supportStyledComponents
13
+
14
+
15
+ core.usePlugins([require.resolve('@modern-js/plugin-design-token/cli')]);
13
16
 
14
17
  var _default = core.createPlugin(() => ({
15
18
  validateSchema() {
@@ -10,6 +10,8 @@ Object.defineProperty(exports, "default", {
10
10
  }
11
11
  });
12
12
 
13
+ require("./types");
14
+
13
15
  var _cli = _interopRequireDefault(require("./cli"));
14
16
 
15
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ require("@modern-js/core");
@@ -1 +1,2 @@
1
+ import './types';
1
2
  export { default } from './cli';
@@ -0,0 +1,6 @@
1
+ import '@modern-js/core';
2
+ declare module '@modern-js/core' {
3
+ interface ToolsConfig {
4
+ tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
5
+ }
6
+ }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.0",
14
+ "version": "1.2.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -33,12 +33,13 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7",
36
- "@modern-js/utils": "^1.2.0",
36
+ "@modern-js/utils": "^1.3.2",
37
+ "@modern-js/plugin-design-token": "^1.0.1",
37
38
  "lodash.clonedeep": "^4.5.0",
38
39
  "lodash.merge": "^4.6.2"
39
40
  },
40
41
  "devDependencies": {
41
- "@modern-js/core": "^1.3.0",
42
+ "@modern-js/core": "^1.4.3",
42
43
  "@scripts/build": "0.0.0",
43
44
  "@types/jest": "^26",
44
45
  "@types/lodash.clonedeep": "^4.5.6",
@@ -51,7 +52,7 @@
51
52
  "@scripts/jest-config": "0.0.0"
52
53
  },
53
54
  "peerDependencies": {
54
- "@modern-js/core": "^1.3.0",
55
+ "@modern-js/core": "^1.4.3",
55
56
  "tailwindcss": "^2.0.4"
56
57
  },
57
58
  "sideEffects": false,
@@ -64,8 +65,7 @@
64
65
  },
65
66
  "publishConfig": {
66
67
  "registry": "https://registry.npmjs.org/",
67
- "access": "public",
68
- "types": "./dist/types/index.d.ts"
68
+ "access": "public"
69
69
  },
70
70
  "scripts": {
71
71
  "new": "modern new",
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "@modern-js/tsconfig/base",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "jsx": "preserve",
6
+ "baseUrl": "./",
7
+ "outDir": "./out",
8
+ "emitDeclarationOnly": true,
9
+ "isolatedModules": true,
10
+ "paths": {},
11
+ "types": ["node", "jest"]
12
+ }
13
+ }
package/src/cli.ts DELETED
@@ -1,77 +0,0 @@
1
- import { Import, PLUGIN_SCHEMAS } from '@modern-js/utils';
2
- import { getTailwindConfig } from './tailwind';
3
-
4
- const core: typeof import('@modern-js/core') = Import.lazy(
5
- '@modern-js/core',
6
- require,
7
- );
8
-
9
- export default core.createPlugin(
10
- () => ({
11
- validateSchema() {
12
- return PLUGIN_SCHEMAS['@modern-js/plugin-tailwindcss'];
13
- },
14
- config() {
15
- return {
16
- tools: {
17
- // TODO: Add interface about postcss config
18
- // TODO: In module project, also is called, but should not be called.
19
- postcss: (config: Record<string, any>) => {
20
- const modernConfig = core.useResolvedConfigContext();
21
- const tailwindConfig = getTailwindConfig(modernConfig, {
22
- pureConfig: {
23
- content: [
24
- './config/html/**/*.html',
25
- './config/html/**/*.ejs',
26
- './config/html/**/*.hbs',
27
- './src/**/*.js',
28
- './src/**/*.jsx',
29
- './src/**/*.ts',
30
- './src/**/*.tsx',
31
- // about storybook
32
- './storybook/**/*',
33
- './styles/**/*.less',
34
- './styles/**/*.css',
35
- './styles/**/*.sass',
36
- './styles/**/*.scss',
37
- ],
38
- },
39
- });
40
- if (Array.isArray(config.postcssOptions.plugins)) {
41
- config.postcssOptions.plugins.push(
42
- require('tailwindcss')(tailwindConfig),
43
- );
44
- } else {
45
- config.postcssOptions.plugins = [
46
- require('tailwindcss')(tailwindConfig),
47
- ];
48
- }
49
- },
50
- },
51
- };
52
- },
53
- moduleTailwindConfig() {
54
- const modernConfig = core.useResolvedConfigContext();
55
- const tailwindConfig = getTailwindConfig(modernConfig, {
56
- pureConfig: {
57
- content: [
58
- './src/**/*.js',
59
- './src/**/*.jsx',
60
- './src/**/*.ts',
61
- './src/**/*.tsx',
62
- './src/**/*.less',
63
- './src/**/*.css',
64
- './src/**/*.sass',
65
- './src/**/*.scss',
66
- './styles/**/*.less',
67
- './styles/**/*.css',
68
- './styles/**/*.sass',
69
- './styles/**/*.scss',
70
- ],
71
- },
72
- });
73
- return require('tailwindcss')(tailwindConfig);
74
- },
75
- }),
76
- { name: '@modern-js/plugin-tailwindcss' },
77
- ) as any;
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from './cli';
package/src/tailwind.ts DELETED
@@ -1,78 +0,0 @@
1
- import type { NormalizedConfig } from '@modern-js/core';
2
- import { Import, applyOptionsChain, logger } from '@modern-js/utils';
3
-
4
- const cloneDeep: typeof import('lodash.clonedeep') = Import.lazy(
5
- 'lodash.clonedeep',
6
- require,
7
- );
8
- const merge: typeof import('lodash.merge') = Import.lazy(
9
- 'lodash.merge',
10
- require,
11
- );
12
-
13
- const checkIfExistNotAllowKeys = (
14
- tailwindConfig: Record<string, any>,
15
- ): [boolean, string] => {
16
- const notAllowExistKeys = ['theme'];
17
- let notAllowKey = '';
18
-
19
- const ret = Object.keys(tailwindConfig).some(
20
- key => notAllowExistKeys.includes(key) && (notAllowKey = key),
21
- );
22
-
23
- return [ret, notAllowKey];
24
- };
25
-
26
- const getPureDesignSystemConfig = (
27
- designSystemConfig: Record<string, any> & {
28
- supportSytledComponents: boolean;
29
- },
30
- ) => {
31
- const pureDesignSystemConfig = cloneDeep(designSystemConfig);
32
- delete pureDesignSystemConfig.supportStyledComponents;
33
- return pureDesignSystemConfig;
34
- };
35
-
36
- const getTailwindConfig = (
37
- config: NormalizedConfig,
38
- option: { pureConfig?: Record<string, any> } = {},
39
- ) => {
40
- const purgeConfig = merge(
41
- {
42
- // TODO: how the operating environment is determined
43
- enabled: process.env.NODE_ENV === 'production',
44
- // TODO: Remove or not
45
- layers: ['utilities'],
46
- content: [],
47
- },
48
- option.pureConfig || {},
49
- );
50
- const defaultTailwindConfig = {
51
- purge: purgeConfig,
52
- };
53
- const tailwindConfig = applyOptionsChain(
54
- defaultTailwindConfig,
55
- (config.tools as any).tailwindcss || {},
56
- );
57
-
58
- const designSystem = getPureDesignSystemConfig(
59
- (config.source as any).designSystem || {},
60
- );
61
-
62
- const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
63
-
64
- if (exist) {
65
- logger.error(
66
- `should not exist '${key}' on tools.tailwindcss, please remove it`,
67
- );
68
- // eslint-disable-next-line no-process-exit
69
- process.exit(0);
70
- }
71
-
72
- // Because there is no default theme configuration
73
- tailwindConfig.theme = designSystem || {};
74
-
75
- return tailwindConfig;
76
- };
77
-
78
- export { getTailwindConfig };
package/src/types.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import '@modern-js/core';
2
-
3
- declare module '@modern-js/core' {
4
- interface ToolsConfig {
5
- tailwind?:
6
- | Record<string, any>
7
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
8
- | ((options: Record<string, any>) => Record<string, any> | void);
9
- }
10
- }