Skip to content

Commit

Permalink
fix: add missing npm dependency. Allow dynamic imports (#461)
Browse files Browse the repository at this point in the history
## Details
- Adding `camelcase` npm package
- Allowing dynamic imports syntax (follow up with lint rule)

## Does this PR introduce a breaking change?
* [x] No
  • Loading branch information
diervo authored Jul 2, 2018
1 parent ff91f08 commit 651494c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/lwc-compiler/src/babel-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ import * as transformPublicFields from '@babel/plugin-proposal-class-properties'
import * as transformObjectRestSpread from '@babel/plugin-proposal-object-rest-spread';

// Base babel configuration
// TODO: Need to remove * on the parserOpts plugin - not advised by babel-core
export const BABEL_CONFIG_BASE = {
babelrc: false,
sourceMaps: true,
parserOpts: { plugins: ['*'] },
parserOpts: { plugins: ['dynamicImport', 'decorators'] },
presets: [],
};

Expand Down
18 changes: 18 additions & 0 deletions packages/lwc-compiler/src/transformers/__tests__/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ describe('Javascript transform', () => {
);
}
});

it('allows dynamic imports', async () => {
const actual = `
export function test() {
return import('/test');
}
`;

const expected = `
export function test() {
return import('/test');
}
`;

const { code } = await transform(actual, 'foo.js', { namespace: 'x', name: 'foo' });
expect(pretify(code)).toBe(pretify(expected));

});
});

describe('HTML transform', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/lwc-template-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"babel-types": "^6.26.0",
"babylon": "^6.17.0",
"decamelize": "^1.2.0",
"camelcase": "~5.0.0",
"he": "^1.1.1",
"parse5-with-errors": "^4.0.1"
}
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2627,6 +2627,10 @@ camelcase@^4.1.0:
version "4.1.0"
resolved "http://npm.lwcjs.org/camelcase/-/camelcase-4.1.0/d545635be1e33c542649c69173e5de6acfae34dd.tgz#d545635be1e33c542649c69173e5de6acfae34dd"

camelcase@~5.0.0:
version "5.0.0"
resolved "http://npm.lwcjs.org/camelcase/-/camelcase-5.0.0/03295527d58bd3cd4aa75363f35b2e8d97be2f42.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42"

caniuse-api@^1.5.2:
version "1.6.1"
resolved "http://npm.lwcjs.org/caniuse-api/-/caniuse-api-1.6.1/b534e7c734c4f81ec5fbe8aca2ad24354b962c6c.tgz#b534e7c734c4f81ec5fbe8aca2ad24354b962c6c"
Expand Down

0 comments on commit 651494c

Please sign in to comment.