Skip to content

Commit

Permalink
Fix braid-site fixture build
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Nov 22, 2023
1 parent c2d86dd commit dbfaa49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
14 changes: 8 additions & 6 deletions packages/core/src/entries/route-data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import path from 'path';

import { transformFileAsync as babelTransform } from '@babel/core';
// @ts-expect-error no types
import babelPluginSyntaxJsx from '@babel/plugin-syntax-jsx';
// @ts-expect-error no types
import babelPluginSyntaxTypescript from '@babel/plugin-syntax-typescript';
import babelPluginRemoveExports from '@crackle/babel-plugin-remove-exports';
import type { RouteData } from '@crackle/router';
import { build as esbuild } from 'esbuild';
import _eval from 'eval';
Expand All @@ -17,12 +22,9 @@ const transformWithBabel = async (file: string) => {
// TODO: merge with src/plugins/vite/strip-route-data.ts
const transformedContents = await babelTransform(file, {
plugins: [
[
require.resolve('@crackle/babel-plugin-remove-exports'),
{ retainExports: ['routeData'] },
],
require.resolve('@babel/plugin-syntax-jsx'),
[require.resolve('@babel/plugin-syntax-typescript'), { isTSX: true }],
[babelPluginRemoveExports, { retainExports: ['routeData'] }],
babelPluginSyntaxJsx,
[babelPluginSyntaxTypescript, { isTSX: true }],
],
babelrc: false,
configFile: false,
Expand Down
11 changes: 8 additions & 3 deletions packages/core/src/plugins/vite/strip-route-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { transformAsync as babelTransform } from '@babel/core';
// @ts-expect-error no types
import babelPluginSyntaxJsx from '@babel/plugin-syntax-jsx';
// @ts-expect-error no types
import babelPluginSyntaxTypescript from '@babel/plugin-syntax-typescript';
import babelPluginRemoveExports from '@crackle/babel-plugin-remove-exports';
import type { Plugin } from 'vite';

export const stripRouteData = (): Plugin => ({
Expand All @@ -13,11 +18,11 @@ export const stripRouteData = (): Plugin => ({
const transformedContents = await babelTransform(code, {
plugins: [
[
require.resolve('@crackle/babel-plugin-remove-exports'),
babelPluginRemoveExports,
{ retainDefault: true, retainIdentifiers: ['React'] },
],
require.resolve('@babel/plugin-syntax-jsx'),
[require.resolve('@babel/plugin-syntax-typescript'), { isTSX: true }],
babelPluginSyntaxJsx,
[babelPluginSyntaxTypescript, { isTSX: true }],
],
babelrc: false,
configFile: false,
Expand Down

0 comments on commit dbfaa49

Please sign in to comment.