Skip to content

Commit

Permalink
Merge branch 'main' into preserve-directives
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins committed Jan 19, 2024
2 parents aa8500e + e8609f0 commit 496217f
Show file tree
Hide file tree
Showing 19 changed files with 136 additions and 0 deletions.
11 changes: 11 additions & 0 deletions integrations/vanilla/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "vanilla-integration",
"private": true,
"type": "module",
"scripts": {
"test:build": "vite build && vitest"
},
"devDependencies": {
"@tanstack/config": "<1.0.0"
}
}
5 changes: 5 additions & 0 deletions integrations/vanilla/snap/cjs/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const utils = require("./utils.cjs");
exports.optionalChaining = utils.optionalChaining;
//# sourceMappingURL=index.cjs.map
1 change: 1 addition & 0 deletions integrations/vanilla/snap/cjs/index.cjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrations/vanilla/snap/cjs/index.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './utils';
8 changes: 8 additions & 0 deletions integrations/vanilla/snap/cjs/utils.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const optionalChaining = (data) => {
var _a;
return (_a = data == null ? void 0 : data.maybe) == null ? void 0 : _a.property;
};
exports.optionalChaining = optionalChaining;
//# sourceMappingURL=utils.cjs.map
1 change: 1 addition & 0 deletions integrations/vanilla/snap/cjs/utils.cjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrations/vanilla/snap/cjs/utils.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const optionalChaining: (data: any) => any;
1 change: 1 addition & 0 deletions integrations/vanilla/snap/esm/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './utils';
5 changes: 5 additions & 0 deletions integrations/vanilla/snap/esm/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrations/vanilla/snap/esm/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrations/vanilla/snap/esm/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const optionalChaining: (data: any) => any;
8 changes: 8 additions & 0 deletions integrations/vanilla/snap/esm/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrations/vanilla/snap/esm/utils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrations/vanilla/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './utils'
3 changes: 3 additions & 0 deletions integrations/vanilla/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const optionalChaining = (data: any) => {
return data?.maybe?.property
}
41 changes: 41 additions & 0 deletions integrations/vanilla/tests/build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { readFileSync, readdirSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'
import { describe, expect, it } from 'vitest'

const __dirname = dirname(fileURLToPath(import.meta.url))
const rootDir = resolve(__dirname, '..')

const esmExtensions = ['.js', '.js.map', '.d.ts']
const cjsExtensions = ['.cjs', '.cjs.map', '.d.cts']

const files = ['index', 'utils']

describe('Check Vanilla build output', () => {
it('should output the same file structure', () => {
const distFiles = readdirSync(`${rootDir}/dist`, { recursive: true })
const snapFiles = readdirSync(`${rootDir}/snap`, { recursive: true })

expect(distFiles).toEqual(snapFiles)
})

it('should build the same ESM output', () => {
files.forEach((file) => {
esmExtensions.forEach((ext) => {
expect(
readFileSync(`${rootDir}/dist/esm/${file}${ext}`).toString(),
).toMatchFileSnapshot(`${rootDir}/snap/esm/${file}${ext}`)
})
})
})

it('should build the same CJS output', () => {
files.forEach((file) => {
cjsExtensions.forEach((ext) => {
expect(
readFileSync(`${rootDir}/dist/cjs/${file}${ext}`).toString(),
).toMatchFileSnapshot(`${rootDir}/snap/cjs/${file}${ext}`)
})
})
})
})
23 changes: 23 additions & 0 deletions integrations/vanilla/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src", "tests", "vite.config.ts"]
}
17 changes: 17 additions & 0 deletions integrations/vanilla/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { mergeConfig, defineConfig } from 'vitest/config'
import { tanstackBuildConfig } from '@tanstack/config/build'

const config = defineConfig({
test: {
name: 'vanilla-integration',
watch: false,
},
})

export default mergeConfig(
config,
tanstackBuildConfig({
entry: 'src/index.ts',
srcDir: 'src',
}),
)
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 496217f

Please sign in to comment.