Skip to content

Commit

Permalink
feat(package): More package name changes
Browse files Browse the repository at this point in the history
Made package name consistent across code
  • Loading branch information
anuraags committed Feb 13, 2020
1 parent b1fe6d3 commit 113503e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 23 deletions.
4 changes: 2 additions & 2 deletions examples/page1.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-env node */
import React from 'react';

import {render} from 'react-entry-loader/render';
import {Module, Styles, Scripts} from 'react-entry-loader/injectors';
import {render} from '@nearmap/react-entry-loader/render';
import {Module, Styles, Scripts} from '@nearmap/react-entry-loader/injectors';

import App from './app';
import GeneratedCode from './code-gen';
Expand Down
4 changes: 2 additions & 2 deletions examples/page2.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-env node */
import React from 'react';

import {hydrate} from 'react-entry-loader/render';
import {Module, Styles, Scripts} from 'react-entry-loader/injectors';
import {hydrate} from '@nearmap/react-entry-loader/render';
import {Module, Styles, Scripts} from '@nearmap/react-entry-loader/injectors';

import App from './app';
import GeneratedCode from './code-gen';
Expand Down
5 changes: 4 additions & 1 deletion src/code-split.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ const isModuleComponent = (path)=> {
/* istanbul ignore else */
if (isReactCreateComponent(path)) {
const [comp] = path.get('arguments');
return comp.referencesImport('react-entry-loader/injectors', 'Module');
return comp.referencesImport(
'@nearmap/react-entry-loader/injectors',
'Module'
);
}
// TODO: we somehow never get here, maybe because we stop traversal
// when we have found the module component.
Expand Down
38 changes: 27 additions & 11 deletions src/code-split.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ describe('App rendered at runtime', ()=> {

const entry = jsx`
import React from 'react';
import render from 'react-entry-loader/render';
import {Module, Styles, Scripts} from 'react-entry-loader/injectors';
import render from '@nearmap/react-entry-loader/render';
import {
Module,
Styles,
Scripts
} from '@nearmap/react-entry-loader/injectors';
import App from './app';
import {theme} from './app.css';
Expand Down Expand Up @@ -53,7 +57,7 @@ describe('App rendered at runtime', ()=> {

expect(code).toBe(jsx`
import React from 'react';
import render from 'react-entry-loader/render';
import render from '@nearmap/react-entry-loader/render';
import App from './app';
import {theme} from './app.css';
const foo = 'needed by app';
Expand All @@ -69,7 +73,11 @@ describe('App rendered at runtime', ()=> {
expect(code).toBe(jsx`
import React from 'react';
import {Module, Styles, Scripts} from 'react-entry-loader/injectors';
import {
Module,
Styles,
Scripts
} from '@nearmap/react-entry-loader/injectors';
const Html = ({scripts, styles})=> (
<html>
Expand All @@ -96,8 +104,12 @@ describe('App rendered at compile time and hydrated at runtiume', ()=> {

const entry = jsx`
import React from 'react';
import {hydrate} from 'react-entry-loader/render';
import {Module, Styles, Scripts} from 'react-entry-loader/injectors';
import {hydrate} from '@nearmap/react-entry-loader/render';
import {
Module,
Styles,
Scripts
} from '@nearmap/react-entry-loader/injectors';
import App from './app';
Expand Down Expand Up @@ -127,7 +139,7 @@ describe('App rendered at compile time and hydrated at runtiume', ()=> {

expect(code).toBe(jsx`
import React from 'react';
import {hydrate} from 'react-entry-loader/render';
import {hydrate} from '@nearmap/react-entry-loader/render';
import App from './app';
hydrate('test-app')(<App />);
Expand All @@ -140,7 +152,11 @@ describe('App rendered at compile time and hydrated at runtiume', ()=> {

expect(code).toBe(jsx`
import React from 'react';
import {Module, Styles, Scripts} from 'react-entry-loader/injectors';
import {
Module,
Styles,
Scripts
} from '@nearmap/react-entry-loader/injectors';
import App from './app';
Expand Down Expand Up @@ -171,7 +187,7 @@ describe('no child to render', ()=> {

const entry = jsx`
import React from 'react';
import {Module, Scripts} from 'react-entry-loader/injectors';
import {Module, Scripts} from '@nearmap/react-entry-loader/injectors';
import {signingSilent} from './silent-signing';
Expand Down Expand Up @@ -206,7 +222,7 @@ describe('no child to render', ()=> {

expect(code).toBe(jsx`
import React from 'react';
import {Module, Scripts} from 'react-entry-loader/injectors';
import {Module, Scripts} from '@nearmap/react-entry-loader/injectors';
const Html = ({scripts})=> (
<html>
Expand All @@ -230,7 +246,7 @@ describe('path removal issues', ()=> {
it('removes variable declarations only if they would be empty', ()=> {
const {code} = getModule(jsx`
import React from 'react';
import {Module, Scripts} from 'react-entry-loader/injectors';
import {Module, Scripts} from '@nearmap/react-entry-loader/injectors';
const foo = 1, bar = '2';
Expand Down
2 changes: 1 addition & 1 deletion src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* * ...props - Props to be sent to the template component in `src`.
*/
const reactEntryLoader = (options)=> (src)=> (
`react-entry-loader?${JSON.stringify(options)}!${src}`
`@nearmap/react-entry-loader?${JSON.stringify(options)}!${src}`
);

export default reactEntryLoader;
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const createLoader = (loaderCtx)=> async (source, sourceMap, meta)=> {
* ```javascript
* {
* entry: {
* page1: 'react-entry-loader?output=page1.html!./src/page1.js'
* page1: '@nearmap/react-entry-loader?output=page1.html!./src/page1.js'
* }
* ...
* }
Expand All @@ -38,7 +38,8 @@ const createLoader = (loaderCtx)=> async (source, sourceMap, meta)=> {
* as default.
* It splits the code into two part: the module and the template code.
* Only the module code will be returned, while the template code is
* sent to the `react-entry-loader/plugin` for generating an HTML asset.
* sent to the `@nearmap/react-entry-loader/plugin` for generating an
* HTML asset.
*
* Code splitting is done by searching for a children of the `<Module />`
* component in the `source`. Those children and all of it's dependencies are
Expand Down
4 changes: 2 additions & 2 deletions src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const sanitize = (html)=> (
const getRequire = (parentContext, compilation, exec)=> (req)=> {
// TODO: needed for tests to be able to import react-entry-loader
// should find a better way to handle this, e.g. using webpack's resolver
if (req.startsWith('react-entry-loader/')) {
req = req.replace('react-entry-loader', __dirname);
if (req.startsWith('@nearmap/react-entry-loader/')) {
req = req.replace('@nearmap/react-entry-loader', __dirname);
}

// TODO: should use webpack's resolver
Expand Down
4 changes: 2 additions & 2 deletions src/testing/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default {
mode: 'development',
resolveLoader: {
alias: {
'react-entry-loader': join(packageDir, 'src')
'@nearmap/react-entry-loader': join(packageDir, 'src')
}
},
resolve: {
alias: {
'react-entry-loader': join(packageDir, 'src')
'@nearmap/react-entry-loader': join(packageDir, 'src')
}
},
output: {
Expand Down

0 comments on commit 113503e

Please sign in to comment.