Skip to content

Commit

Permalink
fix: enable dynamicImport (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist authored Jul 15, 2020
1 parent 04182de commit 39bb586
Show file tree
Hide file tree
Showing 10 changed files with 411 additions and 3,757 deletions.
18 changes: 0 additions & 18 deletions .circleci/config.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
id: pnpm-cache
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- run: npm i -g pnpm
- run: pnpm config set store-dir ~/.pnpm-store
- run: pnpm i
- run: pnpm test
- run: pnpmx semantic-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@egoist/prettier-config"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ You can disable detecting dynamic `import()`-ed modules.
##### parse

Type: `object`<br>
Default: `{sourceType: 'module', plugins: ['jsx', 'typescript']}`
Default: `{sourceType: 'module', plugins: ['jsx', 'typescript', 'dynamicImport']}`

[babel parser](https://github.com/babel/babel/tree/master/packages/babel-parser) parse [options](https://babeljs.io/docs/en/next/babel-parser.html#options).

Expand Down
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const parser = require('@babel/parser')
const traverse = require('@babel/traverse').default

module.exports = function(
module.exports = function (
src,
{
dynamicImport = true,
parse = { sourceType: 'module', plugins: ['jsx', 'typescript'] }
parse = {
sourceType: 'module',
plugins: ['jsx', 'typescript', 'dynamicImport'],
},
} = {}
) {
const modules = { strings: [], expressions: [] }
Expand Down Expand Up @@ -47,7 +50,7 @@ module.exports = function(
modules.strings.push(source.value)
}
}
}
},
})

return modules
Expand Down
19 changes: 5 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,18 @@
"index.js"
],
"scripts": {
"test": "jest && npm run lint",
"lint": "xo index.js __test__/*.test.js"
"test": "node test/test.js"
},
"author": "egoist <0x142857@gmail.com>",
"license": "MIT",
"jest": {
"testEnvironment": "node"
},
"devDependencies": {
"eslint-config-rem": "^3.2.0",
"jest-cli": "^18.1.0",
"xo": "^0.17.1"
},
"xo": {
"extends": "rem/prettier",
"envs": [
"jest"
],
"ignores": [
"**/*/fixture*.js"
]
"@egoist/prettier-config": "^0.1.0",
"esm": "^3.2.25",
"prettier": "^2.0.5",
"uvu": "^0.2.2"
},
"dependencies": {
"@babel/parser": "^7.10.5",
Expand Down
Loading

0 comments on commit 39bb586

Please sign in to comment.