Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
2d76c4a9
Unverified
Commit
2d76c4a9
authored
Jan 14, 2020
by
Joe Haddad
Committed by
GitHub
Jan 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace __NEXT_SPR with __N_SSG Identifier (#10090)
parent
01699c6a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
19 deletions
+19
-19
next-ssg-transform.ts
packages/next/build/babel/plugins/next-ssg-transform.ts
+1
-1
index.js
packages/next/client/index.js
+1
-1
router.ts
packages/next/next-server/lib/router/router.ts
+1
-1
babel-plugin-next-ssg-transform.test.js
test/unit/babel-plugin-next-ssg-transform.test.js
+14
-14
next-babel-loader.test.js
test/unit/next-babel-loader.test.js
+2
-2
No files found.
packages/next/build/babel/plugins/next-ssg-transform.ts
View file @
2d76c4a9
...
@@ -2,7 +2,7 @@ import { NodePath, PluginObj } from '@babel/core'
...
@@ -2,7 +2,7 @@ import { NodePath, PluginObj } from '@babel/core'
import
*
as
BabelTypes
from
'@babel/types'
import
*
as
BabelTypes
from
'@babel/types'
const
pageComponentVar
=
'__NEXT_COMP'
const
pageComponentVar
=
'__NEXT_COMP'
const
prerenderId
=
'__N
EXT_SPR
'
const
prerenderId
=
'__N
_SSG
'
export
const
EXPORT_NAME_GET_STATIC_PROPS
=
'unstable_getStaticProps'
export
const
EXPORT_NAME_GET_STATIC_PROPS
=
'unstable_getStaticProps'
export
const
EXPORT_NAME_GET_STATIC_PATHS
=
'unstable_getStaticPaths'
export
const
EXPORT_NAME_GET_STATIC_PATHS
=
'unstable_getStaticPaths'
...
...
packages/next/client/index.js
View file @
2d76c4a9
...
@@ -94,7 +94,7 @@ class Container extends React.Component {
...
@@ -94,7 +94,7 @@ class Container extends React.Component {
if
(
if
(
(
data
.
nextExport
&&
(
data
.
nextExport
&&
(
isDynamicRoute
(
router
.
pathname
)
||
location
.
search
))
||
(
isDynamicRoute
(
router
.
pathname
)
||
location
.
search
))
||
(
Component
.
__N
EXT_SPR
&&
location
.
search
)
(
Component
.
__N
_SSG
&&
location
.
search
)
)
{
)
{
// update query on mount for exported pages
// update query on mount for exported pages
router
.
replace
(
router
.
replace
(
...
...
packages/next/next-server/lib/router/router.ts
View file @
2d76c4a9
...
@@ -450,7 +450,7 @@ export default class Router implements BaseRouter {
...
@@ -450,7 +450,7 @@ export default class Router implements BaseRouter {
}
}
return
this
.
_getData
<
RouteInfo
>
(()
=>
return
this
.
_getData
<
RouteInfo
>
(()
=>
(
Component
as
any
).
__N
EXT_SPR
(
Component
as
any
).
__N
_SSG
?
this
.
_getStaticData
(
as
)
?
this
.
_getStaticData
(
as
)
:
this
.
getInitialProps
(
:
this
.
getInitialProps
(
Component
,
Component
,
...
...
test/unit/babel-plugin-next-ssg-transform.test.js
View file @
2d76c4a9
...
@@ -40,7 +40,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -40,7 +40,7 @@ describe('babel plugin (next-ssg-transform)', () => {
}
}
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -53,7 +53,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -53,7 +53,7 @@ describe('babel plugin (next-ssg-transform)', () => {
}
}
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -66,7 +66,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -66,7 +66,7 @@ describe('babel plugin (next-ssg-transform)', () => {
}
}
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"export{foo,bar as baz}from'.';const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"export{foo,bar as baz}from'.';const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -86,7 +86,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -86,7 +86,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -106,7 +106,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -106,7 +106,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -124,7 +124,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -124,7 +124,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"export function Noop(){}const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"export function Noop(){}const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -144,7 +144,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -144,7 +144,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -164,7 +164,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -164,7 +164,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -184,7 +184,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -184,7 +184,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"export const foo=2;const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"export const foo=2;const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -202,7 +202,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -202,7 +202,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -220,7 +220,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -220,7 +220,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const a=2;const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const a=2;const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -238,7 +238,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -238,7 +238,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -258,7 +258,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -258,7 +258,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"export class MyClass{}const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"export class MyClass{}const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -305,7 +305,7 @@ describe('babel plugin (next-ssg-transform)', () => {
...
@@ -305,7 +305,7 @@ describe('babel plugin (next-ssg-transform)', () => {
`
)
`
)
expect
(
output
).
toMatchInlineSnapshot
(
expect
(
output
).
toMatchInlineSnapshot
(
`"import keep_me from'hello';import{keep_me2}from'hello2';import*as keep_me3 from'hello3';import{but_not_me}from'bar';var leave_me_alone=1;function dont_bug_me_either(){}const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"import keep_me from'hello';import{keep_me2}from'hello2';import*as keep_me3 from'hello3';import{but_not_me}from'bar';var leave_me_alone=1;function dont_bug_me_either(){}const __NEXT_COMP=function Test(){return __jsx(\\"div\\",null);};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
...
test/unit/next-babel-loader.test.js
View file @
2d76c4a9
...
@@ -303,7 +303,7 @@ describe('next-babel-loader', () => {
...
@@ -303,7 +303,7 @@ describe('next-babel-loader', () => {
{
resourcePath
:
pageFile
,
isServer
:
false
}
{
resourcePath
:
pageFile
,
isServer
:
false
}
)
)
expect
(
code
).
toMatchInlineSnapshot
(
expect
(
code
).
toMatchInlineSnapshot
(
`"import\\"core-js\\";import{bar}from\\"a\\";import baz from\\"b\\";import*as React from\\"react\\";import{yeet}from\\"c\\";import baz3,{cats}from\\"d\\";import{c,d}from\\"e\\";import{e as ee}from\\"f\\";const __NEXT_COMP=function(){return cats+bar();};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"import\\"core-js\\";import{bar}from\\"a\\";import baz from\\"b\\";import*as React from\\"react\\";import{yeet}from\\"c\\";import baz3,{cats}from\\"d\\";import{c,d}from\\"e\\";import{e as ee}from\\"f\\";const __NEXT_COMP=function(){return cats+bar();};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
@@ -325,7 +325,7 @@ describe('next-babel-loader', () => {
...
@@ -325,7 +325,7 @@ describe('next-babel-loader', () => {
{
resourcePath
:
pageFile
,
isServer
:
false
}
{
resourcePath
:
pageFile
,
isServer
:
false
}
)
)
expect
(
code
).
toMatchInlineSnapshot
(
expect
(
code
).
toMatchInlineSnapshot
(
`"var __jsx=React.createElement;import\\"core-js\\";import{bar}from\\"a\\";import baz from\\"b\\";import*as React from\\"react\\";import{yeet}from\\"c\\";import baz3,{cats}from\\"d\\";import{c,d}from\\"e\\";import{e as ee}from\\"f\\";const __NEXT_COMP=function(){return __jsx(\\"div\\",null,cats+bar());};__NEXT_COMP.__N
EXT_SPR
=true export default __NEXT_COMP;"`
`"var __jsx=React.createElement;import\\"core-js\\";import{bar}from\\"a\\";import baz from\\"b\\";import*as React from\\"react\\";import{yeet}from\\"c\\";import baz3,{cats}from\\"d\\";import{c,d}from\\"e\\";import{e as ee}from\\"f\\";const __NEXT_COMP=function(){return __jsx(\\"div\\",null,cats+bar());};__NEXT_COMP.__N
_SSG
=true export default __NEXT_COMP;"`
)
)
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment