Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: convert commonjs packages to esm #598

Merged
merged 27 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
057ecf4
build: convert commonjs packages to esm
brandonroberts Aug 4, 2023
72857c2
chore: update Nx Devkit imports
brandonroberts Aug 10, 2023
d40c44e
chore: rename vite.config.ts to vite.config.mts
brandonroberts Aug 10, 2023
6492884
chore: fix create-analog-e2e tests
brandonroberts Aug 10, 2023
298f063
chore: revert file renames
brandonroberts Aug 10, 2023
ed719dc
chore: cleanup
brandonroberts Aug 10, 2023
b40918d
build: convert commonjs packages to esm
brandonroberts Aug 24, 2023
fd55ebd
Merge branch 'main' into build-esm-packages
brandonroberts Sep 16, 2023
3b230a0
chore: set type module at root, fix E2E tests
brandonroberts Sep 16, 2023
febfddf
chore: rename template
brandonroberts Sep 16, 2023
2479257
chore: rename vite config for analog-app-e2e-playwright
brandonroberts Sep 16, 2023
c949259
Merge branch 'main' into build-esm-packages
brandonroberts Oct 1, 2023
a5397b4
fix: update e2e tests for ESM support
brandonroberts Oct 1, 2023
0527f1f
chore: rename Tailwind/Postcss files
brandonroberts Oct 1, 2023
2c7849f
fix: update e2e test for create-analog
brandonroberts Oct 1, 2023
7572318
chore: rename vite.config.mts files
brandonroberts Oct 1, 2023
34634a0
chore: remove alias
brandonroberts Oct 1, 2023
b562c91
chore: remove offsetFromRoot in vite configs
brandonroberts Oct 1, 2023
39eadbe
Merge branch 'main' into build-esm-packages
brandonroberts Nov 9, 2023
7975ee9
chore: updates
brandonroberts Nov 9, 2023
4c931c1
chore: re-enable Nx Cloud light client
brandonroberts Nov 9, 2023
ce7f8de
Merge branch 'beta' into build-esm-packages
brandonroberts Nov 22, 2023
e9bb905
Merge branch 'beta' into build-esm-packages
brandonroberts Nov 22, 2023
2294dbc
chore: rename release config
brandonroberts Nov 22, 2023
c491110
chore: update vitest cache path for analog-app
brandonroberts Nov 22, 2023
4f5d743
chore: rename app tests
brandonroberts Nov 22, 2023
8c96b28
chore: update lib tests
brandonroberts Nov 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/analog-app-e2e-cypress/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "analog-app-e2e-cypress",
"private": true,
"type": "commonjs"
}
5 changes: 5 additions & 0 deletions apps/analog-app-e2e-playwright/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "analog-app-e2e-playwright",
"private": true,
"type": "commonjs"
}
5 changes: 1 addition & 4 deletions apps/analog-app-e2e-playwright/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import { offsetFromRoot } from '@nx/devkit';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
Expand All @@ -12,9 +11,7 @@ export default defineConfig(({ mode }) => {
environment: 'node',
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot(
'apps/analog-app-e2e-playwright'
)}/node_modules/.vitest/analog-app-e2e-playwright`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
2 changes: 1 addition & 1 deletion apps/analog-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
]
}
},
"test": {
"tests": {
"executor": "@nx/vite:test",
"outputs": ["{projectRoot}/coverage"]
}
Expand Down
5 changes: 1 addition & 4 deletions apps/analog-preset-e2e/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import { offsetFromRoot } from '@nx/devkit';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
Expand All @@ -12,9 +11,7 @@ export default defineConfig(({ mode }) => {
environment: 'node',
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot(
'apps/analog-preset-e2e'
)}/node_modules/.vitest/analog-preset-e2e`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
5 changes: 5 additions & 0 deletions apps/astro-app-e2e-playwright/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "astro-app-e2e-playwright",
"private": true,
"type": "commonjs"
}
5 changes: 1 addition & 4 deletions apps/astro-app-e2e-playwright/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="vitest" />

import { offsetFromRoot } from '@nx/devkit';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
Expand All @@ -11,9 +10,7 @@ export default defineConfig(({ mode }) => {
environment: 'node',
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot(
'packages/astro-app-e2e-playwright'
)}/node_modules/.vitest/astro-app-e2e-playwright`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
2 changes: 1 addition & 1 deletion apps/blog-app-e2e-cypress/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset.js';

const cypressJsonConfig = {
fileServerFolder: '.',
Expand Down
5 changes: 5 additions & 0 deletions apps/blog-app-e2e-cypress/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "blog-app-e2e-cypress",
"private": true,
"type": "commonjs"
}
9 changes: 9 additions & 0 deletions apps/create-analog-e2e/tests/create-analog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ describe.skip('create-analog e2e', () => {
`${tmpDir}/node_modules/@analogjs`
);

const angularJson = JSON.parse(
readFileSync(`${tmpDir}/angular.json`, 'utf-8')
);
angularJson.projects['my-app'].root = '.';
writeFileSync(
`${tmpDir}/angular.json`,
JSON.stringify(angularJson, null, 2)
);

let viteConfig = readFileSync(`${tmpDir}/vite.config.ts`, 'utf-8');
viteConfig = viteConfig.replace(
'analog()',
Expand Down
5 changes: 1 addition & 4 deletions apps/create-analog-e2e/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import { offsetFromRoot } from '@nx/devkit';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
Expand All @@ -12,9 +11,7 @@ export default defineConfig(({ mode }) => {
environment: 'node',
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot(
'apps/create-analog-e2e'
)}/node_modules/.vitest/create-analog-e2e`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
19 changes: 18 additions & 1 deletion apps/nx-plugin-e2e/tests/nx-plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import {
copyNodeModules,
runNxCommandAsync,
uniq,
readFile,
updateFile,
renameFile,
} from '@nx/plugin/testing';

describe('nx-plugin e2e', () => {
describe.skip('nx-plugin e2e', () => {
// Setting up individual workspaces per
// test can cause e2e runs to take a long time.
// For this reason, we recommend each suite only
Expand All @@ -30,6 +33,20 @@ describe('nx-plugin e2e', () => {
);
copyNodeModules(['@analogjs']);

const pkJson = JSON.parse(readFile(`package.json`));
pkJson.type = 'module';
updateFile(`package.json`, JSON.stringify(pkJson, null, 2));
renameFile(`${project}/postcss.config.js`, `${project}/postcss.config.cjs`);
renameFile(
`${project}/tailwind.config.js`,
`${project}/tailwind.config.cjs`
);
const postCssConfig = readFile(`${project}/postcss.config.cjs`);
updateFile(
`${project}/postcss.config.cjs`,
postCssConfig.replace('tailwind.config.js', 'tailwind.config.cjs')
);

await runNxCommandAsync(`test ${project}`);

expect(() => checkFilesExist(`${project}/index.html`)).not.toThrow();
Expand Down
5 changes: 1 addition & 4 deletions apps/nx-plugin-e2e/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import { offsetFromRoot } from '@nx/devkit';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
Expand All @@ -12,9 +11,7 @@ export default defineConfig(({ mode }) => {
environment: 'node',
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot(
'apps/nx-plugin-e2e'
)}/node_modules/.vitest/nx-plugin-e2e`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
5 changes: 1 addition & 4 deletions apps/trpc-app-e2e-playwright/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import { offsetFromRoot } from '@nx/devkit';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
Expand All @@ -12,9 +11,7 @@ export default defineConfig(({ mode }) => {
environment: 'node',
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot(
'apps/trpc-app-e2e-playwright'
)}/node_modules/.vitest/trpc-app-e2e-playwright`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { join } = require('path');
module.exports = {
plugins: {
tailwindcss: {
config: join(__dirname, 'tailwind.config.js'),
config: join(__dirname, 'tailwind.config.cjs'),
},
autoprefixer: {},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/trpc-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"lintFilePatterns": ["apps/trpc-app/**/*.ts", "apps/trpc-app/**/*.html"]
}
},
"test": {
"tests": {
"executor": "@nx/vite:test",
"outputs": ["{projectRoot}/coverage"]
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion libs/card/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"tags": [],
"projectType": "library",
"targets": {
"test": {
"tests": {
"executor": "@nx/vite:test"
},
"lint": {
Expand Down
2 changes: 1 addition & 1 deletion libs/top-bar/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"sourceRoot": "libs/top-bar/src",
"prefix": "analogjs",
"targets": {
"test": {
"tests": {
"executor": "@nx/vite:test"
},
"lint": {
Expand Down
3 changes: 1 addition & 2 deletions libs/top-bar/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import { offsetFromRoot } from '@nx/devkit';
import angular from '@analogjs/vite-plugin-angular';

// https://vitejs.dev/config/
Expand All @@ -15,7 +14,7 @@ export default defineConfig(({ mode }) => {
setupFiles: ['src/test-setup.ts'],
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot('libs/top-bar/src')}/node_modules/.vitest`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "analogjs-platform",
"version": "1.0.0-beta.1",
"license": "MIT",
"type": "module",
"scripts": {
"dev": "nx serve",
"ng": "nx",
Expand Down
2 changes: 1 addition & 1 deletion packages/astro-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getViteConfiguration(vite?: PluginOptions) {
*
*/
plugins: [
(viteAngular as any).default(vite),
viteAngular(vite),
{
name: '@analogjs/astro-angular-platform-server',
transform(code: string, id: string) {
Expand Down
4 changes: 0 additions & 4 deletions packages/astro-angular/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
root: 'src',
resolve: {
mainFields: ['module'],
},
test: {
globals: true,
environment: 'jsdom',
Expand Down
4 changes: 1 addition & 3 deletions packages/content/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import { offsetFromRoot } from '@nx/devkit';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
root: 'src',
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['src/test-setup.ts'],
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot('packages/content/src')}/node_modules/.vitest`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
1 change: 1 addition & 0 deletions packages/create-analog/template-angular-v16/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "my-app",
"version": "0.0.0",
"type": "module",
"private": true,
"engines": {
"node": ">=18.13.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/nx-plugin/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import { offsetFromRoot } from '@nx/devkit';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
Expand All @@ -12,7 +11,7 @@ export default defineConfig(({ mode }) => {
include: ['**/*.spec.ts'],
exclude: ['**/files/**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot('packages/nx-plugin/src')}/node_modules/.vitest`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@analogjs/platform",
"version": "1.0.0-beta.1",
"type": "commonjs",
"type": "module",
"description": "The fullstack meta-framework for Angular",
"author": "Brandon Roberts <[email protected]>",
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions packages/platform/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { platformPlugin } from './lib/platform-plugin';
import { platformPlugin } from './lib/platform-plugin.js';

export { Options } from './lib/options';
export { Options } from './lib/options.js';
export default platformPlugin;
2 changes: 1 addition & 1 deletion packages/platform/src/lib/platform-plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect } from 'vitest';
import { platformPlugin } from './platform-plugin';
import { platformPlugin } from './platform-plugin.js';

vi.mock('@analogjs/vite-plugin-nitro');
vi.mock('./ssr/ssr-build-plugin');
Expand Down
12 changes: 6 additions & 6 deletions packages/platform/src/lib/platform-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Plugin } from 'vite';
import viteNitroPlugin from '@analogjs/vite-plugin-nitro';
import angular from '@analogjs/vite-plugin-angular';

import { Options } from './options';
import { routerPlugin } from './router-plugin';
import { ssrBuildPlugin } from './ssr/ssr-build-plugin';
import { contentPlugin } from './content-plugin';
import { clearClientPageEndpointsPlugin } from './clear-client-page-endpoint';
import { ssrXhrBuildPlugin } from './ssr/ssr-xhr-plugin';
import { Options } from './options.js';
import { routerPlugin } from './router-plugin.js';
import { ssrBuildPlugin } from './ssr/ssr-build-plugin.js';
import { contentPlugin } from './content-plugin.js';
import { clearClientPageEndpointsPlugin } from './clear-client-page-endpoint.js';
import { ssrXhrBuildPlugin } from './ssr/ssr-xhr-plugin.js';

export function platformPlugin(opts: Options = {}): Plugin[] {
const { apiPrefix, ...platformOptions } = {
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"module": "es2020",
"outDir": "../../dist/out-tsc",
"inlineSourceMap": true,
"sourceMap": false,
Expand Down
3 changes: 1 addition & 2 deletions packages/platform/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="vitest" />

import { offsetFromRoot } from '@nx/devkit';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
Expand All @@ -12,7 +11,7 @@ export default defineConfig(({ mode }) => {
setupFiles: ['src/test-setup.ts'],
include: ['**/*.spec.ts'],
cache: {
dir: `${offsetFromRoot('packages/platform/src')}/node_modules/.vitest`,
dir: `../../node_modules/.vitest`,
},
},
define: {
Expand Down
Loading