Skip to content

Commit

Permalink
fix: esm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe committed Apr 17, 2024
1 parent b474f14 commit c77234b
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion angular/examples/my-angular-env/config/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/jest/jest-config
*/
const { jestConfig } = require('@bitdev/angular.angular-env');
const { jestConfig } = require('@bitdev/angular.envs.angular-v17-env/jest/jest.config.cjs');
const { generateNodeModulesPattern } = require('@teambit/dependencies.modules.packages-excluder');
const { defaultTransformerOptions } = require('jest-preset-angular/presets');

Expand Down
2 changes: 1 addition & 1 deletion angular/examples/my-angular-env/config/prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/prettier/prettier-config
*/
const { prettierConfig } = require('@bitdev/angular.envs.base-env');
const { prettierConfig } = require('@bitdev/angular.envs.base-env/config/prettier.config.cjs');

module.exports = {
...prettierConfig,
Expand Down
2 changes: 1 addition & 1 deletion angular/examples/my-angular-env/my-angular-env.bit-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MyAngularEnv extends AngularEnv {
eslint: ESLintLib,
configPath: require.resolve('./config/eslintrc.cjs'),
// resolve all plugins from the angular environment.
pluginsPath: __dirname,
pluginsPath: import.meta.dirname,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs']
};
}
Expand Down
2 changes: 1 addition & 1 deletion angular/examples/my-angular-v13-env/config/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/jest/jest-config
*/
const { jestConfig } = require('@bitdev/angular.envs.angular-v13-env');
const { jestConfig } = require('@bitdev/angular.envs.angular-v13-env/jest/jest.config.cjs');
const { generateNodeModulesPattern } = require('@teambit/dependencies.modules.packages-excluder');

const packagesToExclude = ['@angular', '@ngrx', 'apollo-angular'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/prettier/prettier-config
*/
const { prettierConfig } = require('@bitdev/angular.envs.base-env');
const { prettierConfig } = require('@bitdev/angular.envs.base-env/config/prettier.config.cjs');

module.exports = {
...prettierConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MyAngularV13Env extends AngularV13Env {
eslint: ESLintLib,
configPath: require.resolve('./config/eslintrc.cjs'),
// resolve all plugins from the angular environment.
pluginsPath: __dirname,
pluginsPath: import.meta.dirname,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs']
};
}
Expand Down
2 changes: 1 addition & 1 deletion angular/examples/my-angular-v14-env/config/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/jest/jest-config
*/
const { jestConfig } = require('@bitdev/angular.envs.angular-v14-env');
const { jestConfig } = require('@bitdev/angular.envs.angular-v14-env/jest/jest.config.cjs');
const { generateNodeModulesPattern } = require('@teambit/dependencies.modules.packages-excluder');

const packagesToExclude = ['@angular', '@ngrx', 'apollo-angular'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/prettier/prettier-config
*/
const { prettierConfig } = require('@bitdev/angular.envs.base-env');
const { prettierConfig } = require('@bitdev/angular.envs.base-env/config/prettier.config.cjs');

module.exports = {
...prettierConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MyAngularV14Env extends AngularV14Env {
eslint: ESLintLib,
configPath: require.resolve('./config/eslintrc.cjs'),
// resolve all plugins from the angular environment.
pluginsPath: __dirname,
pluginsPath: import.meta.dirname,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs']
};
}
Expand Down
2 changes: 1 addition & 1 deletion angular/examples/my-angular-v15-env/config/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/jest/jest-config
*/
const { jestConfig } = require('@bitdev/angular.envs.angular-v15-env');
const { jestConfig } = require('@bitdev/angular.envs.angular-v15-env/jest/jest.config.cjs');
const { generateNodeModulesPattern } = require('@teambit/dependencies.modules.packages-excluder');

const packagesToExclude = ['@angular', '@ngrx', 'apollo-angular'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/prettier/prettier-config
*/
const { prettierConfig } = require('@bitdev/angular.envs.base-env');
const { prettierConfig } = require('@bitdev/angular.envs.base-env/config/prettier.config.cjs');

module.exports = {
...prettierConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MyAngularV15Env extends AngularV15Env {
eslint: ESLintLib,
configPath: require.resolve('./config/eslintrc.cjs'),
// resolve all plugins from the angular environment.
pluginsPath: __dirname,
pluginsPath: import.meta.dirname,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs']
};
}
Expand Down
2 changes: 1 addition & 1 deletion angular/examples/my-angular-v16-env/config/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/jest/jest-config
*/
const { jestConfig } = require('@bitdev/angular.envs.angular-v16-env');
const { jestConfig } = require('@bitdev/angular.envs.angular-v16-env/jest/jest.config.cjs');
const { generateNodeModulesPattern } = require('@teambit/dependencies.modules.packages-excluder');
const { defaultTransformerOptions } = require('jest-preset-angular/presets');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/prettier/prettier-config
*/
const { prettierConfig } = require('@bitdev/angular.envs.base-env');
const { prettierConfig } = require('@bitdev/angular.envs.base-env/config/prettier.config.cjs');

module.exports = {
...prettierConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MyAngularV16Env extends AngularV16Env {
eslint: ESLintLib,
configPath: require.resolve('./config/eslintrc.cjs'),
// resolve all plugins from the angular environment.
pluginsPath: __dirname,
pluginsPath: import.meta.dirname,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs']
};
}
Expand Down
2 changes: 1 addition & 1 deletion angular/examples/my-angular-v17-env/config/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/jest/jest-config
*/
const { jestConfig } = require('@bitdev/angular.envs.angular-v17-env');
const { jestConfig } = require('@bitdev/angular.envs.angular-v17-env/jest/jest.config.cjs');
const { generateNodeModulesPattern } = require('@teambit/dependencies.modules.packages-excluder');
const { defaultTransformerOptions } = require('jest-preset-angular/presets');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://bit.dev/reference/prettier/prettier-config
*/
const { prettierConfig } = require('@bitdev/angular.envs.base-env');
const { prettierConfig } = require('@bitdev/angular.envs.base-env/config/prettier.config.cjs');

module.exports = {
...prettierConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MyAngularV17Env extends AngularV17Env {
eslint: ESLintLib,
configPath: require.resolve('./config/eslintrc.cjs'),
// resolve all plugins from the angular environment.
pluginsPath: __dirname,
pluginsPath: import.meta.dirname,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs']
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const jestConfigFile = (angularVersion: number, envPkgName: string) => {
content: `/**
* @see https://bit.dev/reference/jest/jest-config
*/
const { jestConfig } = require('${envPkgName}');
const { jestConfig } = require('${envPkgName}/jest/jest.config.cjs');
const { generateNodeModulesPattern } = require('@teambit/dependencies.modules.packages-excluder');
${angularVersion >= 16 ? `
const { defaultTransformerOptions } = require('jest-preset-angular/presets');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const prettierConfigFile = () => {
content: `/**
* @see https://bit.dev/reference/prettier/prettier-config
*/
const { prettierConfig } = require('@bitdev/angular.envs.base-env');
const { prettierConfig } = require('@bitdev/angular.envs.base-env/config/prettier.config.cjs');
module.exports = {
...prettierConfig,
Expand Down
2 changes: 1 addition & 1 deletion angular/templates/generators/ng-env/files/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class ${Name} extends ${envName} {
eslint: ESLintLib,
configPath: require.resolve('./config/eslintrc.cjs'),
// resolve all plugins from the angular environment.
pluginsPath: __dirname,
pluginsPath: import.meta.dirname,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs']
};
}
Expand Down
6 changes: 5 additions & 1 deletion angular/templates/generators/ng-env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ export class NgEnvTemplate implements ComponentTemplate {
const aspectId: ComponentID = typeof context.aspectId === 'string' ? ComponentID.fromString(context.aspectId) : context.aspectId;
const envId = aspectId.toStringWithoutVersion();
let envPkgName: string;
let jestEnvPkgName: string;
if (this.workspace) {
const envComponent = await this.workspace!.get(aspectId);
envPkgName = this.pkg.getPackageName(envComponent);
jestEnvPkgName = this.pkg.getPackageName(envComponent);
} else if (envId === 'bitdev.angular/angular-env') { // mostly for ci / ripple
envPkgName = '@bitdev/angular.angular-env';
jestEnvPkgName = `@bitdev/angular.envs.angular-v${ this.angularVersion }-env`;
} else {
envPkgName = `@bitdev/angular.envs.angular-v${ this.angularVersion }-env`;
jestEnvPkgName = `@bitdev/angular.envs.angular-v${ this.angularVersion }-env`;
}
return [
{
Expand All @@ -62,7 +66,7 @@ export class NgEnvTemplate implements ComponentTemplate {
content: envFile(context, this.envName, this.angularVersion, envPkgName)
},
eslintConfigFile(),
jestConfigFile(this.angularVersion, envPkgName),
jestConfigFile(this.angularVersion, jestEnvPkgName),
prettierConfigFile(),
tsConfigFile(),
tsConfigSpecFile(),
Expand Down

0 comments on commit c77234b

Please sign in to comment.