Skip to content

Commit

Permalink
refactor(transform): 플러그인맵 상수 폴더로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
Danji-ya committed Nov 11, 2023
1 parent 60640fd commit 9546126
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
14 changes: 14 additions & 0 deletions src/transform/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import transformStrictMode from '../transform-strict-mode.js';
import transformEsmToCjs from '../transform-esm-to-cjs.js';

export const DEFAULT_OPTIONS = {
requireCode: true,
requireAst: false,
};

export const DEFAULT_IMPORT_KEYWORD = '_default';

export const PLUGIN_MAP = {
strictMode: {
plugin: transformStrictMode,
conditions: [],
},
esmToCjs: {
plugin: transformEsmToCjs,
conditions: [],
},
};
15 changes: 1 addition & 14 deletions src/transform/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
import { transformFromAstSync } from '@babel/core';
import transformEsmToCjs from './transform-esm-to-cjs.js';
import transformStrictMode from './transform-strict-mode.js';
import { DEFAULT_OPTIONS } from './constants/index.js';
import { DEFAULT_OPTIONS, PLUGIN_MAP } from './constants/index.js';

const getActualOptions = (options) =>
Object.assign({}, DEFAULT_OPTIONS, options);

const PLUGIN_MAP = {
strictMode: {
plugin: transformStrictMode,
conditions: [],
},
esmToCjs: {
plugin: transformEsmToCjs,
conditions: [],
},
};

const transform = (ast, content, options) => {
const { requireAst, requireCode, ...restOptions } = getActualOptions(options);

Expand Down

0 comments on commit 9546126

Please sign in to comment.