Skip to content

Commit

Permalink
es subpath 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
shine1594 committed Jan 7, 2021
1 parent a253a9c commit b2d9ca3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ module.exports = (api) => {
],
];

if (BABEL_ENV === "mjs") {
plugins.push("./scripts/transform_import_fxjs.cjs");
}

return {
presets: [
[
"@babel/preset-env",
{
targets,
modules: BABEL_ENV === "mjs" ? false : "auto",
},
],
],
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
"type": "module",
"scripts": {
"generate:index": "node scripts/index_generator.js",
"copy-files": "rm src/index.js && mv src/_internal ./ && mv src/*.js ./ && rm -rf src",
"copy-es-files": "mkdir es && cp -r ./src/* ./es",
"build:modern": "NODE_ENV=production BABEL_ENV=modern webpack",
"build:legacy": "NODE_ENV=production BABEL_ENV=legacy webpack",
"build": "npm run generate:index && npm run build:modern && npm run build:legacy && npm run copy-files",
"transpile": "BABEL_ENV=mjs babel src/ --out-dir ./",
"build": "npm run build:modern && npm run build:legacy && npm run generate:index && mv -f ./index.js src/ && npm run copy-es-files && npm run transpile && rm -rf src/",
"deploy": "np --no-publish --no-tests && npm run build && npm publish",
"test:server": "node ./test/server.cjs"
},
"files": [
"dist",
"_internal",
"dist/",
"_internal/",
"es/",
"*.js"
],
"repository": {
Expand Down
11 changes: 11 additions & 0 deletions scripts/transform_import_fxjs.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = () => ({
visitor: {
ImportDeclaration(path, state) {
const { source } = path.node;
const { value } = source;
if (value.startsWith("fxjs/es")) {
source.value = source.value.replace('fxjs/es', 'fxjs');
}
},
},
});

0 comments on commit b2d9ca3

Please sign in to comment.