Skip to content

Commit

Permalink
feat: support export namespace from syntax (resolves #84)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 19, 2022
1 parent 3e4dcbb commit ebb59cf
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -25,6 +25,7 @@
"devDependencies": {
"@babel/core": "^7.19.1",
"@babel/plugin-proposal-decorators": "^7.19.1",
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
"@babel/plugin-syntax-class-properties": "^7.12.13",
Expand Down
22 changes: 22 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/babel.ts
Expand Up @@ -15,7 +15,8 @@ export default function transform (opts: TransformOptions): TRANSFORM_RESULT {
[require('@babel/plugin-transform-modules-commonjs'), { allowTopLevelThis: true }],
[require('babel-plugin-dynamic-import-node'), { noInterop: true }],
[TransformImportMetaPlugin, { filename: opts.filename }],
[require('@babel/plugin-syntax-class-properties')]
[require('@babel/plugin-syntax-class-properties')],
[require('@babel/plugin-proposal-export-namespace-from')]
]
}

Expand Down
3 changes: 2 additions & 1 deletion test/__snapshots__/fixtures.test.ts.snap
Expand Up @@ -47,7 +47,8 @@ TypeError: The \\"listener\\" argument must be of type function. Received undefi
exports[`fixtures > error-runtime > stdout 1`] = `""`;
exports[`fixtures > esm > stdout 1`] = `
"{
"{ utilsLib: { utils: { a: 'a', default: 'default' }, version: '123' } }
{
file: '<cwd>/test.js',
dir: '<cwd>',
'import.meta.url': 'file://<cwd>/test.js',
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/esm/index.js
@@ -1,3 +1,7 @@
import test from './test'

import * as utilsLib from './utilsLib'

console.log({ utilsLib })

console.log(test())
2 changes: 2 additions & 0 deletions test/fixtures/esm/utils.js
@@ -0,0 +1,2 @@
export const a = 'a'
export default 'default'
3 changes: 3 additions & 0 deletions test/fixtures/esm/utilsLib.js
@@ -0,0 +1,3 @@
export const version = '123'

export * as utils from './utils'

0 comments on commit ebb59cf

Please sign in to comment.