Comments (7)
Hi,
I haven't tried Rollup yet, but it looks like it doesn't like the import * as something from 'something'
syntax.
Unfortunately the only way to fix it is to change the way we import classnames
in the library, unless you are using typescript in you application. In that case you simply need to add synthetic default imports in your tsconfig.json
:
"allowSyntheticDefaultImports": true,
Sorry for the inconvenience, I'll change the import for next version and do some tests with a Rollup setup ;)
from react.
Interesting. We're using Rollup to bundle angular-ui-router which should be nearly the same, right?
from react.
Don't know as I am not using that one at the moment---I did have success using Rollup to bundle ui-router for angular 2, both for JIT and AOT mode. But no joy for the React version and Rollup.
from react.
Tried bundling ui-router-react, got the error:
(79): lib-esm/reactViews.jsðš Cannot call a namespace ('classNames')
lib-esm/components/UISref.js (49:23)
47: onClick: this.handleClick,
48: href: this.context['router'].stateService.href(to, params, options),
49: className: classNames(this.props.className, childrenProps.className)
^
50: });
51: return cloneElement(this.props.children, props);
rollup.config.js:
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import progress from 'rollup-plugin-progress';
import sourcemaps from 'rollup-plugin-sourcemaps';
import visualizer from 'rollup-plugin-visualizer';
var pkg = require('./package.json');
var banner =
`/**
* ${pkg.description}
* @version v${pkg.version}
* @link ${pkg.homepage}
* @license MIT License, http://www.opensource.org/licenses/MIT
*/`;
var uglifyOpts = { output: {} };
// retain multiline comment with @license
uglifyOpts.output.comments = (node, comment) =>
comment.type === 'comment2' && /@license/i.test(comment.value);
var plugins = [
nodeResolve({jsnext: true}),
commonjs(),
progress(),
sourcemaps(),
uglify(uglifyOpts),
visualizer({ sourcemap: true }),
];
const CONFIG = {
sourceMap: true,
format: 'umd',
exports: 'named',
plugins: plugins,
banner: banner,
moduleName: 'ui-router-react',
entry: 'lib-esm/index.js',
dest: '_bundles/ui-router-react.min.js',
external: ['react', 'react-dom'],
};
export default CONFIG;
from react.
from react.
Here's an issue reported for "classnames" + typescript + synthetic default + webpack
microsoft/TypeScript#7518 (comment)
TypeScript has no runtime support for synthetic defaults, it simply allows for the fact they may be present at runtime. It is the module loader (SystemJS in this case) that creates the synthetic default.
It appears that this might be a webpack thing?
from react.
So, I'm trying to find out the problem.
It looks like TS wants the import * as X from Y
syntax to handle modules which don't have a default import. I never used this syntax before using typescript (unless I wanted to include all exports in a single object) because babel changes the way default export are transpiled (microsoft/TypeScript#11057).
On the other hand, rollup doesn't like that syntax (as pointed out here rollup/rollup#670) hence the problem.
A solution would probably be to add babel and let it transpile the export in the modules, but I don't like it as we don't need babel.
I guess the "magic" solution works for now, and we'll change it accordingly once we'll find a better solution.
from react.
Related Issues (20)
- Can ui-router/react support React18 new features? HOT 6
- testing ui router with relative paths
- {location: 'replace'} doesn't work in stateService.go(stateName, params, {location: 'replace'}) HOT 1
- useSref: "target="_blank" ignored when link contains child elements HOT 1
- Is this project still under active development? HOT 3
- Use same UIRouter instance inside different React.render(...) HOT 1
- Typescript demo errors on `1.0.1` HOT 1
- animating-transitions demo errors on `1.0.1` HOT 1
- Router.start() called more than once HOT 1
- 404 on react-dom.js on the tutorial pages HOT 2
- Path duplication after page refresh when using UIRouter pushStateLocationPlugin HOT 4
- Params of type json are not deserialized properly HOT 5
- States not gets enabled if there are nested lazy loaded states HOT 2
- UIView Doesn't Render with Usage of `urlService.rules.when` HOT 4
- Scroll restoration HOT 3
- Cannot use useRouter HOT 4
- Jest/Enzyme Transition Rejection/TypeError HOT 1
- UISref Component ignores target="_blank" on child anchor tag HOT 3
- Mocking UiRouter Classes with Jest HOT 4
- useCurrentStateAndParams don't reacting on initial state HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
ð Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ððð
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â€ïž Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.