Skip to content

Commit

Permalink
feat: services submodule, remove React components (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley authored Feb 2, 2022
1 parent 1304535 commit 9966c03
Show file tree
Hide file tree
Showing 30 changed files with 186 additions and 382 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ node_modules/
/tests/nextjs/public/
/tests/benchmarks/screenshots/
/tests/videos/
/services/
/tsc/
/utils/
/index.cjs
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
},
"./react/index.mjs": "./react/index.mjs",
"./react/index.cjs": "./react/index.cjs",
"./services/index.mjs": "./services/index.mjs",
"./services/index.cjs": "./services/index.cjs",
"./services": {
"import": "./services/index.mjs",
"require": "./services/index.cjs"
},
"./utils": {
"import": "./utils/index.mjs",
"require": "./utils/index.cjs"
Expand All @@ -41,6 +47,7 @@
"integration/",
"lib/",
"react/",
"services/",
"utils/"
],
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Extractor, ExtractorConfig } from '@microsoft/api-extractor';
export function buildApi(opts: BuildOptions) {
console.log('👑 Generate API types\n');

const dirs = [opts.srcIntegrationDir, opts.srcReactDir, opts.srcUtilsDir];
const dirs = [opts.srcIntegrationDir, opts.srcServicesDir, opts.srcReactDir, opts.srcUtilsDir];
dirs.forEach((dir) => {
const extractorConfig = ExtractorConfig.loadFileAndPrepare(join(dir, 'api-extractor.json'));
const result = Extractor.invoke(extractorConfig, {
Expand Down
29 changes: 29 additions & 0 deletions scripts/build-services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { BuildOptions, submodulePackageJson } from './utils';
import { join } from 'path';
import type { OutputOptions, RollupOptions } from 'rollup';

export function buildServices(opts: BuildOptions): RollupOptions {
const output: OutputOptions[] = [
{
file: join(opts.distServicesDir, 'index.cjs'),
format: 'cjs',
},
{
file: join(opts.distServicesDir, 'index.mjs'),
format: 'es',
},
];

return {
input: join(opts.tscServicesDir, 'index.js'),
output,
plugins: [
submodulePackageJson(
'@builder.io/partytown/services',
opts.srcServicesDir,
opts.distServicesDir,
opts
),
],
};
}
2 changes: 1 addition & 1 deletion scripts/build-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BuildOptions, submodulePackageJson, submodulePath } from './utils';
import { BuildOptions, submodulePackageJson } from './utils';
import { join } from 'path';
import type { RollupOptions } from 'rollup';

Expand Down
8 changes: 8 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { buildMediaImplementation } from './build-media-implementations';
import { buildMainSnippet } from './build-main-snippet';
import { buildReact } from './build-react';
import { buildServiceWorker } from './build-service-worker';
import { buildServices } from './build-services';
import { buildUtils } from './build-utils';
import { emptyDir, ensureDir, readJsonSync, writeFile } from 'fs-extra';
import { join } from 'path';
Expand All @@ -25,6 +26,7 @@ export async function runBuild(rootDir: string, isDev: boolean, generateApi: boo
...buildAtomics(opts),
buildMediaImplementation(opts),
buildIntegration(opts),
buildServices(opts),
buildReact(opts),
buildUtils(opts),
];
Expand Down Expand Up @@ -63,13 +65,15 @@ async function createRootPackage(opts: BuildOptions) {

function createBuildOptions(rootDir: string, isDev: boolean, generateApi: boolean) {
const distIntegrationDir = join(rootDir, 'integration');
const distServicesDir = join(rootDir, 'services');
const distLibDir = join(rootDir, 'lib');
const distLibDebugDir = join(distLibDir, 'debug');
const distReactDir = join(rootDir, 'react');
const distUtilsDir = join(rootDir, 'utils');

const srcDir = join(rootDir, 'src');
const srcIntegrationDir = join(srcDir, 'integration');
const srcServicesDir = join(srcDir, 'services');
const srcLibDir = join(srcDir, 'lib');
const srcReactDir = join(srcDir, 'react');
const srcUtilsDir = join(srcDir, 'utils');
Expand All @@ -82,6 +86,7 @@ function createBuildOptions(rootDir: string, isDev: boolean, generateApi: boolea
const tscDir = join(rootDir, 'tsc');
const tscSrcDir = join(tscDir, 'src');
const tscIntegrationDir = join(tscSrcDir, 'integration');
const tscServicesDir = join(tscSrcDir, 'services');
const tscLibDir = join(tscSrcDir, 'lib');
const tscReactDir = join(tscSrcDir, 'react');
const tscUtilsDir = join(tscSrcDir, 'utils');
Expand All @@ -96,6 +101,7 @@ function createBuildOptions(rootDir: string, isDev: boolean, generateApi: boolea
rootDir,

distIntegrationDir,
distServicesDir,
distLibDir,
distLibDebugDir,
distTestsLibDir,
Expand All @@ -105,6 +111,7 @@ function createBuildOptions(rootDir: string, isDev: boolean, generateApi: boolea

srcDir,
srcIntegrationDir,
srcServicesDir,
srcLibDir,
srcReactDir,
srcUtilsDir,
Expand All @@ -114,6 +121,7 @@ function createBuildOptions(rootDir: string, isDev: boolean, generateApi: boolea

tscDir,
tscIntegrationDir,
tscServicesDir,
tscLibDir,
tscReactDir,
tscUtilsDir,
Expand Down
3 changes: 3 additions & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,22 @@ export interface BuildOptions {
distIntegrationDir: string;
distLibDir: string;
distLibDebugDir: string;
distServicesDir: string;
distTestsLibDir: string;
distTestsLibDebugDir: string;
distReactDir: string;
distUtilsDir: string;
srcDir: string;
srcIntegrationDir: string;
srcServicesDir: string;
srcLibDir: string;
srcReactDir: string;
srcUtilsDir: string;
testsDir: string;
testsVideosDir: string;
tscDir: string;
tscIntegrationDir: string;
tscServicesDir: string;
tscLibDir: string;
tscReactDir: string;
tscUtilsDir: string;
Expand Down
2 changes: 1 addition & 1 deletion src/integration/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"apiReport": {
"enabled": true,
"reportFileName": "api.md",
"reportFolder": "<projectFolder>/src/",
"reportFolder": "<projectFolder>/src/integration/",
"reportTempFolder": "<projectFolder>/.cache/api-extractor/integration/"
},
"dtsRollup": {
Expand Down
23 changes: 0 additions & 23 deletions src/api.md → src/integration/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,16 @@
```ts

// @public
export const appendForwardConfig: (...forwards: PartytownForwardProperty[]) => string;

// Warning: (ae-forgotten-export) The symbol "ApplyHookOptions" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type ApplyHook = (opts: ApplyHookOptions) => any;

// @public
export const facebookPixel: (opts: {
pixelId: string;
}) => string;

// @public
export const facebookPixelForward: () => PartytownForwardProperty[];

// @public
export const freshpaintForward: () => PartytownForwardProperty[];

// Warning: (ae-forgotten-export) The symbol "GetHookOptions" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type GetHook = (opts: GetHookOptions) => any;

// @public
export const googleTagManager: (opts: {
containerId: string;
dataLayerName?: string;
}) => string;

// @public
export const googleTagManagerForward: () => PartytownForwardProperty[];

// @public
export interface PartytownConfig {
// (undocumented)
Expand Down
16 changes: 0 additions & 16 deletions src/integration/forward.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ import type { PartytownConfig } from '../lib/types';
export const partytownSnippet = (config: PartytownConfig) =>
createSnippet(config, PartytownSnippet);

export { appendForwardConfig } from './forward';
export { SCRIPT_TYPE } from '../lib/utils';

export * from './services/facebook-pixel';
export * from './services/freshpaint';
export * from './services/google-tag-manager';

export type {
PartytownConfig,
PartytownForwardProperty,
Expand Down
21 changes: 0 additions & 21 deletions src/integration/services/facebook-pixel.ts

This file was deleted.

24 changes: 0 additions & 24 deletions src/integration/services/google-tag-manager.ts

This file was deleted.

27 changes: 1 addition & 26 deletions src/react/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,7 @@
```ts

// @public
export const FacebookPixel: ({ pixelId, enablePartytown }: FacebookPixelProps) => any;

// @public (undocumented)
export const FacebookPixelNoScript: ({ pixelId }: FacebookPixelProps) => any;

// @public
export interface FacebookPixelProps {
enablePartytown?: boolean;
pixelId: string;
}

// @public
export const GoogleTagManager: ({ containerId, dataLayerName, enablePartytown, }: GoogleTagManagerProps) => any;

// @public
export const GoogleTagManagerNoScript: ({ containerId }: GoogleTagManagerProps) => any;

// @public
export interface GoogleTagManagerProps {
containerId: string;
dataLayerName?: string;
enablePartytown?: boolean;
}

// @public
export const Partytown: (props?: PartytownProps | undefined) => any;
export const Partytown: (props?: PartytownProps) => any;

// Warning: (ae-forgotten-export) The symbol "PartytownConfig" needs to be exported by the entry point index.d.ts
//
Expand Down
17 changes: 0 additions & 17 deletions src/react/forward.tsx

This file was deleted.

14 changes: 1 addition & 13 deletions src/react/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
export { Partytown, PartytownProps } from './library';

export {
FacebookPixel,
FacebookPixelNoScript,
FacebookPixelProps,
} from './integration/facebook-pixel';

export {
GoogleTagManager,
GoogleTagManagerNoScript,
GoogleTagManagerProps,
} from './integration/google-tag-manager';
export { Partytown, PartytownProps } from './snippet';
Loading

1 comment on commit 9966c03

@vercel
Copy link

@vercel vercel bot commented on 9966c03 Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.