From aee98936879e4185f1afa51cd7e059e1195a8450 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 6 Aug 2020 23:03:55 +0200 Subject: [PATCH] Complete Renaming --- example/package.json | 3 +-- example/yarn.lock | 8 +------- package.json | 5 +++-- src/{plugin.ts => index.ts} | 12 ++++++++++-- src/{index.tsx => tools.tsx} | 5 +---- test/pages/class component/output.js | 4 ++-- test/pages/gSSP function declaration/output.js | 4 ++-- test/pages/separate export declaration/output.js | 4 ++-- test/pages/transforms a valid example/output.js | 4 ++-- test/plugin.test.ts | 2 +- tools.js | 1 + tsdx.config.js | 4 ++-- 12 files changed, 28 insertions(+), 28 deletions(-) rename src/{plugin.ts => index.ts} (94%) rename src/{index.tsx => tools.tsx} (86%) create mode 100644 tools.js diff --git a/example/package.json b/example/package.json index 539516c..544f0c6 100644 --- a/example/package.json +++ b/example/package.json @@ -13,8 +13,7 @@ "next": "9.5.1", "react": "16.13.1", "react-dom": "16.13.1", - "superjson": "^1.1.0", - "superjson-with-next": "file:../" + "superjson": "^1.1.0" }, "devDependencies": { "@types/react": "^16.9.44", diff --git a/example/yarn.lock b/example/yarn.lock index 826aefb..7875d6e 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -1790,7 +1790,7 @@ babel-plugin-dynamic-import-node@^2.3.3: dependencies: object.assign "^4.1.0" -"babel-plugin-superjson-next@file:../": +"babel-plugin-superjson-next@file:..": version "0.1.0" dependencies: "@babel/core" "^7.11.0" @@ -7003,12 +7003,6 @@ stylis@3.5.4: resolved "https://registry.yarnpkg.com/stylis/-/stylis-3.5.4.tgz#f665f25f5e299cf3d64654ab949a57c768b73fbe" integrity sha512-8/3pSmthWM7lsPBKv7NXkzn2Uc9W7NotcwGNpJaa3k7WMM1XDCA4MgT5k/8BIexd5ydZdboXtU90XH9Ec4Bv/Q== -"superjson-with-next@file:..": - version "0.1.0" - dependencies: - "@babel/core" "^7.11.0" - "@babel/helper-module-imports" "^7.10.4" - superjson@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/superjson/-/superjson-1.1.0.tgz#61c99b416295a18b69a65ccb1fa2eca65efaa65a" diff --git a/package.json b/package.json index 982eb65..a3157a7 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "typings": "dist/index.d.ts", "files": [ "dist", - "src" + "src", + "tool.js" ], "engines": { "node": ">=10" @@ -35,7 +36,7 @@ }, "name": "babel-plugin-superjson-next", "author": "Simon Knott", - "module": "dist/superjson-with-next.esm.js", + "module": "dist/babel-plugin-superjson-next.esm.js", "devDependencies": { "@types/react": "^16.9.44", "babel-plugin-tester": "^9.2.0", diff --git a/src/plugin.ts b/src/index.ts similarity index 94% rename from src/plugin.ts rename to src/index.ts index a4c3947..22562c2 100644 --- a/src/plugin.ts +++ b/src/index.ts @@ -71,11 +71,19 @@ function transformGetServerSideProps( } function addWithSuperJSONGSSPImport(path: NodePath) { - return addNamedImport(path, 'withSuperJSONGSSP', 'superjson-with-next'); + return addNamedImport( + path, + 'withSuperJSONGSSP', + 'babel-plugin-superjson-next/tools' + ); } function addWithSuperJSONPageImport(path: NodePath) { - return addNamedImport(path, 'withSuperJSONPage', 'superjson-with-next'); + return addNamedImport( + path, + 'withSuperJSONPage', + 'babel-plugin-superjson-next/tools' + ); } function superJsonWithNext(): PluginObj { diff --git a/src/index.tsx b/src/tools.tsx similarity index 86% rename from src/index.tsx rename to src/tools.tsx index c92e7ac..1ab86cb 100644 --- a/src/index.tsx +++ b/src/tools.tsx @@ -1,7 +1,6 @@ import SuperJSON from 'superjson'; -import { GetServerSideProps } from 'next'; +import type { GetServerSideProps } from 'next'; import React from 'react'; -import babelPlugin from './plugin'; type SuperJSONResult = any; @@ -25,5 +24,3 @@ export function withSuperJSONPage

( return ; }; } - -export default babelPlugin; diff --git a/test/pages/class component/output.js b/test/pages/class component/output.js index b28a599..e2f1857 100644 --- a/test/pages/class component/output.js +++ b/test/pages/class component/output.js @@ -1,5 +1,5 @@ -import { withSuperJSONPage as _withSuperJSONPage } from 'superjson-with-next'; -import { withSuperJSONGSSP as _withSuperJSONGSSP } from 'superjson-with-next'; +import { withSuperJSONPage as _withSuperJSONPage } from 'babel-plugin-superjson-next/tools'; +import { withSuperJSONGSSP as _withSuperJSONGSSP } from 'babel-plugin-superjson-next/tools'; export const getServerSideProps = _withSuperJSONGSSP(async () => { const products = [ { diff --git a/test/pages/gSSP function declaration/output.js b/test/pages/gSSP function declaration/output.js index c8688e7..0049154 100644 --- a/test/pages/gSSP function declaration/output.js +++ b/test/pages/gSSP function declaration/output.js @@ -1,5 +1,5 @@ -import { withSuperJSONPage as _withSuperJSONPage } from 'superjson-with-next'; -import { withSuperJSONGSSP as _withSuperJSONGSSP } from 'superjson-with-next'; +import { withSuperJSONPage as _withSuperJSONPage } from 'babel-plugin-superjson-next/tools'; +import { withSuperJSONGSSP as _withSuperJSONGSSP } from 'babel-plugin-superjson-next/tools'; export const getServerSideProps = _withSuperJSONGSSP( async function getServerSideProps() { const products = [ diff --git a/test/pages/separate export declaration/output.js b/test/pages/separate export declaration/output.js index d2210e7..0bbd97c 100644 --- a/test/pages/separate export declaration/output.js +++ b/test/pages/separate export declaration/output.js @@ -1,5 +1,5 @@ -import { withSuperJSONPage as _withSuperJSONPage } from 'superjson-with-next'; -import { withSuperJSONGSSP as _withSuperJSONGSSP } from 'superjson-with-next'; +import { withSuperJSONPage as _withSuperJSONPage } from 'babel-plugin-superjson-next/tools'; +import { withSuperJSONGSSP as _withSuperJSONGSSP } from 'babel-plugin-superjson-next/tools'; export const getServerSideProps = _withSuperJSONGSSP(async () => { const products = [ { diff --git a/test/pages/transforms a valid example/output.js b/test/pages/transforms a valid example/output.js index d2210e7..0bbd97c 100644 --- a/test/pages/transforms a valid example/output.js +++ b/test/pages/transforms a valid example/output.js @@ -1,5 +1,5 @@ -import { withSuperJSONPage as _withSuperJSONPage } from 'superjson-with-next'; -import { withSuperJSONGSSP as _withSuperJSONGSSP } from 'superjson-with-next'; +import { withSuperJSONPage as _withSuperJSONPage } from 'babel-plugin-superjson-next/tools'; +import { withSuperJSONGSSP as _withSuperJSONGSSP } from 'babel-plugin-superjson-next/tools'; export const getServerSideProps = _withSuperJSONGSSP(async () => { const products = [ { diff --git a/test/plugin.test.ts b/test/plugin.test.ts index 3a5982e..eba20fb 100644 --- a/test/plugin.test.ts +++ b/test/plugin.test.ts @@ -1,4 +1,4 @@ -import superJsonWithNext from '../src/plugin'; +import superJsonWithNext from '../src'; import pluginTester from 'babel-plugin-tester'; import * as path from 'path'; diff --git a/tools.js b/tools.js new file mode 100644 index 0000000..7d557a4 --- /dev/null +++ b/tools.js @@ -0,0 +1 @@ +module.exports = require("./dist/tools.js") \ No newline at end of file diff --git a/tsdx.config.js b/tsdx.config.js index 8841b87..10d3231 100644 --- a/tsdx.config.js +++ b/tsdx.config.js @@ -3,8 +3,8 @@ module.exports = { return { ...config, input: [ - "src/plugin.ts", - "src/index.tsx" + "src/index.ts", + "src/tools.tsx" ], output: { ...config.output,