zephyr-modernjs-plugin 0.0.0-canary.11 → 0.0.0-canary.12

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/.eslintrc.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "extends": ["../../.eslintrc.json"],
3
+ "ignorePatterns": ["!**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts", "*.tsx"],
7
+ "parserOptions": {
8
+ "project": ["libs/zephyr-modernjs-plugin/tsconfig.*?.json"]
9
+ },
10
+ "rules": {}
11
+ },
12
+ {
13
+ "files": ["*.ts", "*.tsx"],
14
+ "rules": {
15
+ "@typescript-eslint/explicit-function-return-type": [
16
+ "error",
17
+ {
18
+ "allowExpressions": true
19
+ }
20
+ ]
21
+ }
22
+ },
23
+ {
24
+ "files": ["*.js", "*.jsx"],
25
+ "rules": {}
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1 @@
1
+ {"version":"5.8.3"}
package/jest.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ /* eslint-disable */
2
+ export default {
3
+ displayName: 'zephyr-modernjs-plugin',
4
+ preset: '../../jest.preset.js',
5
+ testEnvironment: 'node',
6
+ transform: {
7
+ '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8
+ },
9
+ moduleFileExtensions: ['ts', 'js', 'html'],
10
+ coverageDirectory: '../../coverage/libs/zephyr-modernjs-plugin',
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zephyr-modernjs-plugin",
3
- "version": "0.0.0-canary.11",
3
+ "version": "0.0.0-canary.12",
4
4
  "description": "Modernjs plugin for Zephyr",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,9 +19,9 @@
19
19
  "@modern-js/app-tools": "^2.68.14",
20
20
  "is-ci": "^4.1.0",
21
21
  "tslib": "^2.8.1",
22
- "zephyr-agent": "0.0.0-canary.11",
23
- "zephyr-edge-contract": "0.0.0-canary.11",
24
- "zephyr-xpack-internal": "0.0.0-canary.11"
22
+ "zephyr-agent": "0.0.0-canary.12",
23
+ "zephyr-edge-contract": "0.0.0-canary.12",
24
+ "zephyr-xpack-internal": "0.0.0-canary.12"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/is-ci": "3.0.4",
@@ -31,8 +31,8 @@
31
31
  "ts-jest": "^29.2.6"
32
32
  },
33
33
  "peerDependencies": {
34
- "zephyr-webpack-plugin": "0.0.0-canary.11",
35
- "zephyr-rspack-plugin": "0.0.0-canary.11"
34
+ "zephyr-rspack-plugin": "0.0.0-canary.12",
35
+ "zephyr-webpack-plugin": "0.0.0-canary.12"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "zephyr-rspack-plugin": {
package/project.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "zephyr-modernjs-plugin",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "libs/zephyr-modernjs-plugin/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "build": {
9
+ "executor": "@nx/js:tsc",
10
+ "outputs": ["{options.outputPath}"],
11
+ "options": {
12
+ "rootDir": "libs/zephyr-modernjs-plugin/src",
13
+ "outputPath": "libs/zephyr-modernjs-plugin/dist",
14
+ "tsConfig": "libs/zephyr-modernjs-plugin/tsconfig.lib.json",
15
+ "main": "libs/zephyr-modernjs-plugin/src/index.ts"
16
+ }
17
+ },
18
+ "publish": {
19
+ "command": "node tools/scripts/publish.mjs zephyr-modernjs-plugin {args.ver} {args.tag}",
20
+ "dependsOn": ["build"]
21
+ },
22
+ "release": {
23
+ "command": "pnpm dist-tag add zephyr-modernjs-plugin@$(npm view zephyr-modernjs-plugin@next version) latest"
24
+ },
25
+ "lint": {
26
+ "executor": "@nx/eslint:lint",
27
+ "outputs": ["{options.outputFile}"]
28
+ },
29
+ "test": {
30
+ "executor": "@nx/jest:jest",
31
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
32
+ "options": {
33
+ "jestConfig": "libs/zephyr-modernjs-plugin/jest.config.ts"
34
+ }
35
+ }
36
+ }
37
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { withZephyr } from './modernjs-plugin/with-zephyr';
@@ -0,0 +1,62 @@
1
+ import type { AppTools, CliPluginFuture } from '@modern-js/app-tools';
2
+ import { ze_log } from 'zephyr-agent';
3
+ import type { ZephyrPluginOptions } from 'zephyr-edge-contract';
4
+
5
+ const pluginName = 'zephyr-modernjs-plugin';
6
+ const isDev = process.env['NODE_ENV'] === 'development';
7
+
8
+ export const withZephyr = (
9
+ zephyrOptions?: ZephyrPluginOptions
10
+ ): CliPluginFuture<AppTools<'rspack' | 'webpack'>> => ({
11
+ name: pluginName,
12
+ pre: ['@modern-js/plugin-module-federation-config'],
13
+
14
+ async setup(api) {
15
+ api.modifyWebpackConfig(async (config, utils) => {
16
+ const currentBundler = api.getAppContext().bundlerType;
17
+ if (currentBundler !== 'webpack') {
18
+ return;
19
+ }
20
+
21
+ const { withZephyr } = await import('zephyr-webpack-plugin');
22
+ const z_config = await withZephyr(zephyrOptions)(config);
23
+ /* eslint-disable-next-line */
24
+ utils.mergeConfig(config as any, z_config as any);
25
+ });
26
+
27
+ api.modifyRspackConfig(async (config, utils) => {
28
+ const currentBundler = api.getAppContext().bundlerType;
29
+ if (currentBundler !== 'rspack') {
30
+ return;
31
+ }
32
+
33
+ const { withZephyr } = await import('zephyr-rspack-plugin');
34
+ const z_config = await withZephyr(zephyrOptions)(config);
35
+ utils.mergeConfig(config, z_config);
36
+ });
37
+ },
38
+
39
+ usePlugins: isDev ? [zephyrFixPublicPath()] : [],
40
+ });
41
+
42
+ function zephyrFixPublicPath(): CliPluginFuture<AppTools> {
43
+ return {
44
+ name: 'zephyr-publicpath-fix',
45
+ pre: [pluginName],
46
+ setup(api) {
47
+ api.modifyWebpackConfig(async (config, { isServer }) => {
48
+ if (!isServer) {
49
+ ze_log.misc('Modifying publicPath for Dev Server');
50
+ config.output = { ...config.output, publicPath: 'auto' };
51
+ }
52
+ });
53
+
54
+ api.modifyRspackConfig(async (config, { isServer }) => {
55
+ if (!isServer) {
56
+ ze_log.misc('Modifying publicPath for Dev Server');
57
+ config.output = { ...config.output, publicPath: 'auto' };
58
+ }
59
+ });
60
+ },
61
+ };
62
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "target": "ES2020",
6
+ "forceConsistentCasingInFileNames": true,
7
+ "strict": true,
8
+ "noImplicitOverride": true,
9
+ "noPropertyAccessFromIndexSignature": true,
10
+ "noImplicitReturns": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "allowSyntheticDefaultImports": true
13
+ },
14
+ "files": [],
15
+ "include": [],
16
+ "references": [
17
+ {
18
+ "path": "./tsconfig.lib.json"
19
+ },
20
+ {
21
+ "path": "./tsconfig.spec.json"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "declaration": true,
6
+ "types": ["node"]
7
+ },
8
+ "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
9
+ "include": ["src/**/*.ts"]
10
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "types": ["jest", "node"]
6
+ },
7
+ "include": [
8
+ "jest.config.ts",
9
+ "src/**/*.test.ts",
10
+ "src/**/*.spec.ts",
11
+ "src/**/*.d.ts"
12
+ ]
13
+ }